Weather App React Hooks - Can anyone help?


I’ve tried to make the local weather app with React Hooks, but its not working and I’m not sure why. Seems like some times it does work and sometimes no data comes back. Here is a link to the code sandbox - Weather App 1.2 (forked) - CodeSandbox

Can anyone figure out what is wrong with it?


1 Like

When I look at your code, I see that the network call doesn’t have data:

  1. Request URL:
  2. Request Method: GET
  3. Status Code: 200

On a quick look, it doesn’t appear that getCurrentPosition is calling its callbacks - I can’t see why yet.

1 Like

If I add a timeout:

    navigator.geolocation.getCurrentPosition(onSuccess, onError, {
      timeout: 5000

It is timing out for me - but I don’t know if that is because of the VPN on my work computer or something else.

1 Like

oh, ok thanks for this!

1 Like