I got a little brainbug, and I hope somebody could help me: I cant set a variable as a “part of the object-path”:
(last 2 lines)
var yzClick = function(args) {
console.log(JSON.stringify(args.data)); // OUTPUT: "abc123"
var yzfield = args.data
return fetch( YZ_URL2.value)
.then(function(response) { return response.json(); })
.then(function(responseObject) {
console.log(yzfield); // OUTPUT: abc123
console.log( JSON.stringify(responseObject.fields[0].yzfield)); // OUTPUT: undefined
console.log( JSON.stringify(responseObject.fields[0].abc123)); //OUTPUT: {"name1":"test","name2:"test2"}
});
}
I tried different things like responseObject.fields[0].${yzfield}
or responseObject.fields[0] + yzfield
( I know it was stupid)
Any help would be AWESOME
Gratefully
John