Unbundle JSON with Function Node and Add New Key

Hi All. I’m using a function node to unbundle an api response
return items[0].json.records.map(x => ({ json: x }));

but i’d need to add a new key to each item
const apiKey = '123456';

What would be the best practice to achieve this? Thanks!

This’ll work:

return items[0].json.records.map(x => {
    x.apiKey = '123456';
    return {json: x};
});
4 Likes

@shrey-42 Thanks for helping out! Much appreciated!