I'm new to typescript. I have a input array like this,
filter = [
{
field : "eventId",
value : "123"
},
{
field : "baseLocation",
value : "singapore"
}
]
I need this array of objects to be like,
..test.com?search=eventid%20eq%20123&search=baselocation%20eq%20singapore
I tried like this, but nothing happens,
var test = '';
if (filter != undefined && filter.length > 0)
filter.array.forEach(item => {
test += Object.keys(item).map(k => `${k}=${encodeURIComponent(item[k])}`);
});
console.log(test);
console log is always empty. Can this be done in a better way?
Please note that i need all field values in lower case instead of camelcase. Please assist.
filter.map(a => 'search=' + encodeURIComponent(a.field.toLowerCase() + '=' + a.value.toLowerCase())).join('&')