https://somesite.com/crm.contact.add.json?fields%5BNAME%5D=LOREM&fields%5BSECOND_NAME%5D=IPSUM&fields%5BLAST_NAME%5D=DOLOR
const OBJECT = {
fields: {
NAME: 'LOREM',
SECOND_NAME: 'IPSUM',
LAST_NAME: 'DOLOR',
}
};
const OBJECT = {
fields: {
NAME: 'LOREM',
SECOND_NAME: 'IPSUM',
LAST_NAME: 'DOLOR',
}
};
const url = new URL('https://somesite.com/crm.contact.add.json');
for (const [name, value] of Object.entries(OBJECT.fields)) {
url.searchParams.append(`fields[${name}]`, value);
}
console.log(url.href);