mercredi 23 juin 2021

OpenWeather API 401 error on accessing the hourly forecast data

fetch(
    `http://api.openweathermap.org/data/2.5/forecast/hourly?q=${cityName}&appid=${API_KEY}`,
  )
    .then((response) => response.json())
    .then((data) => console.log(data));

I am trying to use the OpenWeather API to get a given city's hourly forecast data which is apparently available for the free version users too but I get the 401 - Invalid API key error:

Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.

I have tried the fetch URL in both api.open... and pro.open... forms and I am using the same key that I used for accessing their current weather API which works fine. I tried with a new key and that didn't work too. I am not making any mistake listed in their faq.




Aucun commentaire:

Enregistrer un commentaire