I have a javascript object that I need to flatten into a string so that I can pass as querystring, how would I do that? i.e:
{ cost: 12345, insertBy: \'testUse
you can use this
function serialize(obj) { let str = [] for(var p in obj) { if(obj.hasOwnProperty(p)) str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p])) } return str.join('&') }
try on JSFiddle on this link https://jsfiddle.net/yussan/kwmnkca6/