'Mongoose: searching via two separate search params
In my routes.js I am attempting to make a new route:
app.route('/dashboard/:userID/:event')
.get(getEvents)
controller.js file:
export const getEvents = ((req, res) => {
Gift.find({userID: req.params.userID, event: req.params.event}, (err, user) => {
if(err) {
res.send(err)
}
res.json(user)
})
})
When I test the route in postman I cannot pull the data. How do I search via multiple parameters (":userID/:event") e.g. localhost:3000/dashboard/823094809643435/picnic ?
When I had a single dynamic parameter: "/dashboard/:event" , my same controller function pulled the data, but I don't know how to query for two specific params. The goal being that GET requests on event data will be associated with the userID, to make the event name specific to that users event pool.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
