I want to query the yelp api, and have the following route:
When I make a GET request to
I get the error
Cannot GET /yelp?term=food&location=austin
What am I doing wrong?
In the requested url
- base url/address is
- route used for matching is
- querystring url-encoded data is
?term=food&location=austini.e. data is everything after ?
Query strings are not considered when peforming these matches, for example “GET /” would match the following route, as would “GET /?name=tobi”.
So you should either :
- use app.get(“/yelp”) and extract the term and location from req.query like
- use app.get(“/yelp/term/:term/location/:location”) but modify the url accordingly as luto described.
Answered By – user568109