Seems to be a problem with the FCC Weather API

Based on numerous Help category posts concerning reports of weather projects randomly returning the weather for Japan even with valid latitude and longitude values, I decided to do some further research and noticed my own weather app and the FCC demo shown on the project page is also showing this issue. There is no error message, but about 50-75% of the time, the response returned contains the weather for Shuzenji, JP. I believe this is the default response if the lat and lon provided are not valid. In all cases that I have checked, the lat and lon are valid.

See below for a screenshot of the FCC Weather App demo:

I have opened a ticket for the issue. Hopefully, it will be addressed quickly.

7 Likes

I think it has to do with the browser not sending the geolocation data when the page loads. If I rerun the code from the console, after I click “Allow” for my location, I get the correct JSON back from the API.

Actually, it’s because the API is just a wrapper for another API. That other API has strict rate-limiting, which means that sometimes the API you’re using won’t be able to access any fresh data. When that happens, it accesses a cache (a saved copy of results). The idea was to pick from one of the results it’s seen before, the weather data that is closest to the requested geolocation. However, the bit that actually saves the data wasn’t coded yet (and it’s unclear as to whether it will be finished, for non-technical reasons), and so there’s only one cached value, that was put there as a sort of test of the whole caching system. That location is the nearest one to the one you request (obviously! it’s the only one :wink:) , and so that’s the one which is returned, even if it’s nowhere near where you are.

I’ve submitted a corrected copy of the code, which instead spits out a descriptive error message. However, the API isn’t hosted on GitHub, instead on glitch.me, and so not many people have write-access. It’s just a matter of time before someone who has the ability to fix the issue reviews my changes and decides whether an error message is the right way to go. :slightly_smiling_face:

7 Likes

This explains why when I refresh the page, 5/6 times I get weather for Shuzenji, JP when coordinates are correct and successful GET request with correct coordinates. I had tried callbacks, nesting the functions, and finally jQuery deferred to no avail. Thank you for this explanation as I can finally move on.

1 Like

Here is a quick workaround I used on my project:

if (result.name !="Shuzenji"){//Weather API has a bug that shows this location sometimes
              //Code to insert API data into HTML
            }
1 Like

@joker314 thanks for the explanation-always good to hear it’s a server side thing :slight_smile: Not my problem!

@jgBayo great to include some kind of error handling for this issue :slight_smile:

Cheers! The only downside is that if you are actually in Shuzenji, you can never check the weather :sweat_smile:

1 Like