I have an object like this:
const params = {
'userId[]': [1, 2],
'empId': 2,
advance: 'hello',
};
and I want to make a string like this:
userId[]=1&userId[]=2&empId=2&advance=hello
I am trying like this:
const myResult = Object.entries(params)
.map(([key, value]) => {
if (Array.isArray(value)) {
let result;
value.forEach(item => {
`${key}=${value}`
})
return result
}
// return
})
.join('&');
console.log(myResult);
but not able to figure out what to do next.