1

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.