I am using queryString with react to mutate some urls for api calls.
I have next code
useEffect(() => {
const parsed = queryString.parseUrl(window.location.href);
console.log('parsed',parsed)
console.log(parsed.query.type=[parsed.query.type,'partime'])
parsed.query.type = []
if (fulltime) {
parsed.query.type = [...parsed.query.type, 'fulltime'];
}
if (parttime) {
parsed.query.type = [...parsed.query.type, 'parttime'];
}
setHref(queryString.stringifyUrl(parsed));
}
)
Problem is, queryString.stringifyUrl(parsed) //returns /?type=fulltime?type=parttime
but i want /?type=fulltime,parttime
while I was typing this answer in frustration, as usual I found solution myself.
we can add any type of option from arguments we are using in "parsing" of a url to the stringifyUrl\Stringify