Hey
I have this JSON object in an variable called res.
And with the code below I try to print out the title value “Happy”.
console.log(res.items.item[0].title._text);
And it does not print out anything, anybody?
#json
Hey
I have this JSON object in an variable called res.
And with the code below I try to print out the title value “Happy”.
console.log(res.items.item[0].title._text);
And it does not print out anything, anybody?
#json
I’ve gone over this numerous times and just don’t see anything. Can you stringify the JSON and post it here so we can take a crack at it? Or create a test site/page and post the editor URL.
Did you manage to resolve this? I have a similar issue. Console log shows the correct data but when I try to change text value to this data it comes back as undefined!
Back end code:
.then(json => json.data[0].icao)
.then(json => console.log(JSON.stringify(json)))
Console log returns: “EGKK”
Front End Code:
weatherCheck($w("#input1").value)
.then(icao => $w("#text10").text = "test: " + icao);
Returns:
test: undefined
Not sure whats going wrong!
I’ve managed to solve this!
What was the solution?
This seemed to work for me (back end):
.then(function (json) {
var myJSON = JSON.stringify(json)
console.log("JSON Returned: " + myJSON)
return json
})
Then I could change text in front end using below:
.then(myJSON => $w("#text10").text = myJSON.data[0].icao)