Setting the key of an object to the value of an variable

msg.payload = myObject('DGWZ_temp_offset');
node.send(msg);
return null;

function myObject(key){
let value = global.get(key);
return = {key.valueOf():value}; ????????
}

result should be {'DGWZ_temp_offset':value}

your help is very much appreciated.

Try...

return = {[key]: value};
1 Like

Hi Steve,
many thanks!
it works ok :slight_smile:
Hannes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.