Reputation: 1357
I have the following axios query
axios
.get(`/api/school/get-pathways-with-partner`, {
params: { partnerList: e }
})
And my express route is this:
router.get(
`/get-pathways-with-partner/:partnerList`)
However, when I hit the router with the query
http://localhost:5000/api/school/get-pathways-with-partner?partnerList[]=%7B%22value%22:%22Accenture%22,%22label%22:%22Accenture%22,%22_id%22:%225c9ba397347bb645e0865278%22%7D
It gives me a 404, is there something wrong with how i'm defining the route?
Upvotes: 1
Views: 5891
Reputation: 6491
You are defining your route with a route parameter, while it looks like you want the params to be regular query parameters.
That is, instead of reading from req.params
, you want to read from req.query
.
So instead of having this route
app.get('/get-pathways-with-partner/:partnerList', (req, res) => {
let { partnerList } = req.params;
});
You should have the following:
app.get('/get-pathways-with-partner/', (req, res) => {
let { partnerList } = req.query;
});
See the stackoverflow post at Node.js: Difference between req.query[] and req.params for more information.
Upvotes: 1