How to get multiple JSON objects using nodejs and mongoose?

前端 未结 2 1182
小鲜肉
小鲜肉 2021-01-27 13:25

I want to get all the JSON objects having season:2008 or season:2009. For season field there are 2008,2009,2010,2011,2012,2013,2014,2015,2016 values.

相关标签:
2条回答
  • 2021-01-27 13:54

    Now your both the routes are identical...you have to make different routes for both queries... because queries does not know what is match_id and session... if you keep same name for the routes then query which is before in the code will be executed first

    change your both the routes

        app.get('/api/match_id/:match_id)
    
        app.get(/api/matches/:season)
    
    0 讨论(0)
  • 2021-01-27 13:58

    Before http://localhost:5000/api/matches/2010 before the /api/matches/:season there should be a route name. Lets say your route name is match.js you the url would look like http://localhost:5000/match/api/matches/2010. Depends how you defined the index.js

    0 讨论(0)
提交回复
热议问题