#Explaination: Why did rearranging the order of controller functions work

9 messages · Page 1 of 1 (latest)

cyan plover
#

Please I want to learn and know why rearranging the order of the controller functions in my code worked, previously I was getting this response

#

This was the code before.\

#

When I refactored and moved the code up, I started to get the desired response. Please can someone explain why this happened?

Thanks

latent schooner
#

that's because the GET /:id will overwrite GET /search

#

because of the :id placeholder

#

this is mentioned somewhere in the docs

#

and so you must ensure that GET /search is declared before the GET /:id route

#

and the routes registration order is the same as the order of calling @Get(), etc, decorators

cyan plover
#

Oh that makes sense now. Thanks so much @latent schooner