When I'm setting an anonymous callback function on some REST service, I'm getting a very strange behavior where if I simply console.log the result of the REST service, I get the expected payload (an array of Objects). However, when I run a loop over the same array and try get some key's value, I get a error because apparently the item is undefined
...
callback: (result) => {
console.log(result); // outputs [{text: 'foo'}, {text: 'bar'}]
for(let item of result){
console.log(item.text); // error can't read text of undefined
console.log(item); // HOWEVER... this works... :/
}
}
Any ideas? There must be some kind of async behavior happening, but I can't figure it out.
Thanks!
responseis really as in the comment?