I am sending a get request to API with axios , but unable to acess the passed parametrs in that request.
Here is my code: API request
axios.get('http://localhost:4000/students',{
params: {
category:"indoor"
}
})
Request handling
router.route('/').get((req, res) => {
console.log(req.params.category);
studentSchema.find({category:req.params.category},(error, data) => {
if (error) {
return next(error)
} else {
res.json(data)
}
})
})
Routing is working properly when there is no parameters given.
console.log(req.params.category); is giving output as undefined.
Hope you got the Problem...