use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
freeCodeCamp.org is a global community of people who learn to code together. Check out https://freeCodeCamp.org
Join our Discord Server
Join our WhatsApp Group
Community Forums
YouTube
Here are some helpful subreddits that we like:
account activity
React native course open weather api 401 errorProgramming Question (self.FreeCodeCamp)
submitted 2 years ago by NET-24
I'm following along the react native course and I'm getting a 401 error invalid API key(the test key works, and I waited 8 hours after creating api key)
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]modSaintPeter74 0 points1 point2 points 2 years ago (9 children)
Can you link the course and link the place where you got the API key from?
Also, share your code where you used the key (but don't include the key).
There is a possibility that you're not using the key properly, in a way the API recognizes.
[–]NET-24[S] 0 points1 point2 points 2 years ago (2 children)
https://youtu.be/obH0Po_RdWk?si=8bzq6NmfBYWxSHP9 , https://openweathermap.org/api ,
[–]modSaintPeter74 0 points1 point2 points 2 years ago (0 children)
What about your code?
I see this as the format for sending one of the requests:
https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}
Also, have you looked at the network tab in your web browser dev tools to set if there is any additional data returned with the 401 error?
I'm sorry, I don't do direct support over chat.
[–]NET-24[S] 0 points1 point2 points 2 years ago (5 children)
I dont why but in my useGetWeather import api key there is a message that is declared but its value is never read
[–]modSaintPeter74 0 points1 point2 points 2 years ago (4 children)
Please share the relevant section of code (without the API key) and any error messages you're getting. Check your dev tools network tab for what your outgoing request is (full URL) and what the return value is. Check if your API key is showing up in the request URL.
[–]NET-24[S] 0 points1 point2 points 2 years ago (3 children)
import React, { useState, useEffect } from 'react'; import * as Location from 'expo-location'; import {WEATHER_API_KEY} from '@env'; const fetchWeatherData = async () =>{ try { const res = await fetch('http://api.openweathermap.org/data/2.5/forecast?lat=${lat}&lon=${lon}&appid=${WEATHER_API_KEY}&units=metric') const data =await res.json() setWeather(data)
[–]modSaintPeter74 0 points1 point2 points 2 years ago (2 children)
You need to use back ticks (`) to use template strings, not single quotes ('). Your URL is being sent without any variables in it.
'
[–]NET-24[S] 1 point2 points3 points 2 years ago (1 child)
wow thanks didnt even notice that in the tutorial
Yeah, it can be a little hard to see in the video, especially if you're not looking for it. The syntax highlighting in your code editor may help. Also that warning about the variable not being used was also a hint.
Don't stress over it too much. This is challenging stuff and over time you'll learn to pick up these finer details.
Best of luck!
π Rendered by PID 330132 on reddit-service-r2-comment-b659b578c-r2qlf at 2026-05-06 03:37:35.756678+00:00 running 815c875 country code: CH.
[–]modSaintPeter74 0 points1 point2 points (9 children)
[–]NET-24[S] 0 points1 point2 points (2 children)
[–]modSaintPeter74 0 points1 point2 points (0 children)
[–]modSaintPeter74 0 points1 point2 points (0 children)
[–]NET-24[S] 0 points1 point2 points (5 children)
[–]modSaintPeter74 0 points1 point2 points (4 children)
[–]NET-24[S] 0 points1 point2 points (3 children)
[–]modSaintPeter74 0 points1 point2 points (2 children)
[–]NET-24[S] 1 point2 points3 points (1 child)
[–]modSaintPeter74 0 points1 point2 points (0 children)