0

I am attempting to develop a weather website project using NodeJS Express and Axios, integrating the OpenWeather API to retrieve current weather data. However, I'm encountering authorization issues despite activating the API key.

I have followed the documentation provided by OpenWeather to properly integrate the API into my NodeJS Express application. I have obtained an API key and made sure it is correctly included in the API request URLs. I've tested the API key activation by accessing the API directly through the browser, and it returns invalid data.

I expect to successfully retrieve current weather data using the provided API endpoints. Specifically, I aim to fetch weather information for a given city using the /weather endpoint and for a specific location using the /onecall endpoint.

{"cod":401, "message": "Invalid API key. Please see https://openweathermap.org/faq#error401 for more info."}

{
 "cod": 401,
 "message": "Please note that using One Call 3.0 requires a separate subscription to the One Call by Call plan. Learn more here https://openweathermap.org/price. If you have a valid subscription to the One Call by Call plan, but still receive this error, then please see https://openweathermap.org/faq#error401 for more info."
}
VLAZ
29.6k9 gold badges65 silver badges88 bronze badges
asked May 14, 2024 at 8:13
7
  • Show the code. Show how you are calling the API and providing the key. Give working example to work with. Commented May 14, 2024 at 8:16
  • I think you need to subscribe to One Call API 3.0. The API is no longer free I guess. openweathermap.org/api Commented May 14, 2024 at 8:25
  • Are you referring to a paid subscription?? Commented May 14, 2024 at 8:31
  • how m i supposed to show uh source code sorry I am new to stackoverflow and copy pasting says too long text Commented May 14, 2024 at 8:43
  • try { const { lat, lon } = req.params; const url = ${baseUrl}/weather?lat=${lat}&lon=${lon}&appid=${apiKey}; const response = await axios.get(url); res.json(response.data); } catch (error) { res.status(500).json({ error: error.message }); } }); @chankruze Commented May 14, 2024 at 9:02

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.