Just getting started with typescript and looking for some help. I have an input array structured like this:
filter = [
{
field : "eventId",
value : "123"
},
{
field : "baseLocation",
value : "singapore"
}
]
The desired format for this array of objects is as follows:
..test.com?search=eventid%20eq%20123&search=baselocation%20eq%20singapore
I attempted the following code but it didn't yield any results:
var test = '';
if (filter != undefined && filter.length > 0)
filter.forEach(item => {
test += Object.keys(item).map(k => `${k}=${encodeURIComponent(item[k])}`);
});
console.log(test);
Every time I check the console log, it's empty. Is there a better approach to achieve this?
Please keep in mind that I require all field values to be in lowercase instead of camelcase. Any guidance on how to accomplish this would be greatly appreciated.