我知道如何获得这样的查询的参数:
app.get('/sample/:id', routes.sample);
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我可以req.params.id用来获取参数(例如2in /sample/2).
但是,对于url来说/sample/2?color=red,如何访问变量color?
我试过req.params.color但它没用.
我想查询yelp api,并有以下路由:
app.get("/yelp/term/:term/location/:location", yelp.listPlaces)
Run Code Online (Sandbox Code Playgroud)
当我向GET请求时
http://localhost:3000/yelp?term=food&location=austin,
我收到了错误
Cannot GET /yelp?term=food&location=austin
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?