Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to do history.push for multiple parameter with multiple value (array) in react

I’m using React router, onClick of the dropdown value (which is multi selection) I’m trying to push value to the parameter, value I’m passing is an array but somehow in the URL it’s showing only a single value. How do I send multiple values as one parameter?

Could anyone suggest a solution?

     var study_dashboard=['abc','xyz','pqr']
       history.push(
          `/dashboard/filter?name=${study_dashboard}`
        );

Thanks

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You could use JSON.stringify to convert the array into a JSON notation string.

var study_dashboard=['abc','xyz','pqr']
history.push(
    `/dashboard/filter?name=${JSON.stringify(study_dashboard)}`
);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading