I'm trying to convert my object to a query string but I have an array as the values
my object looks like this
filterChoice: {
role: ["SW", "EW"]
source: ["Secondary", "Tertiary"]
}
I've gotten halfway with my conversion
const toQueryString = `?${Object.keys(filterChoice)
.map(key => `${key}=${filterChoice[key].toString()}`)
.join('&')}`
which outputs: ?source=Secondary,Tertiary&role=SW,EW
but I would like this output to look like this
?source=Secondary&source=Tertiary&role=SW&role=EW
Could anyone help me out?
role[]=SW&role[]=EW. Nice to know. Thanks for the clarification.