1

I am trying to pass the array with the help of query string but when i am fetching it using nodejs it act as a string.

my query string is like -

'/home?page='+value;

  where value is [{name : 'a'},{name :'b'},{name : 'c'}]

but the problem is when i send it in node js and apply

console.log(req.query.page[0].name) output is [object object] but i want the output a

Please help me in this problem

2

1 Answer 1

1

I think the problem might be that you are sending a raw object as a parameter. Try doing '/home?page=' + JSON.stringify(value) and console.log(JSON.parse(req.query.page[0].name)).

You may also need to encode the param like so: ecodeURI(JSON.stringify(value)) and decode with decodeURI, like so: decodeURI(req.query.page[0].name)

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

1 Comment

thanx perfect answer.

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.