I am desperatly trying to add values to an object property. The API I want to communicate with needs all information delivered that way and the amount of values vary.
msg.object is setup as an array, but only with a single object. There is no push method for objects, you will need to create new properties:
let obj = [{ property: { key_1: "value1" } }]
let key2 = "key_2"
let key2_value = "value2"
let setObj = obj[0].property // first get the property key from the single array and create new keys from there.
setObj[key2] = key2_value
// or as a short hand you could do:
// obj[0].property[key2] = key2_value
msg.object = obj
return msg;
bakman2 I cannot thank you enough! Your solution works like a charm! To generate an unknown amount of property keys I just had to adjust a little bit of your code to let it act like the push method