Web API not pulling correct data from Open Weather Map

I have a weather app am working on and so far able to collect certain data correctly but unable to pull the exact name tag.

At the bottom of the json file, when I try to get the “name” tag, it comes up as “Earth” instead of “Green Wood”

	"timezone": 3600,
	"id": 7302135,
	"name": "Green Wood",
	"cod": 200
}

OK found the issue but a strange one. When I get my current location, the latitude and longitude values are up to 7 decimal places. Using these vales for unknown reason does not read that tag correctly but when I hardcode the values displayed from openweathermap json file which are rounded up to 2 decimal places, then it displays “Green Wood”

Nah its random, sometimes it shows the name and sometimes it shows Earth :frowning:

You received location values ​​that consist of 7 decimal places. Round out up to 2 characters and use it. The result coincided with when you hard code them? If not, then there is an error somewhere.

I can assume the following situation:

There are several fields in your json data with the key “name”. If you get these fields with the help of the “get” list block, then due to a list indexing error, in one case you may get index 2, and in the other 1. Accordingly, each time the data will be different. Or another option - in different cases different json is returned.

2 Likes

Hi and thanks for reply. It was actually an error on my part. I placed the addMarker block in wrong place hence reason why it did not work as expected. Now all OK.