https://home.openweathermap.org/
Members
Enter your email address and we will send you a link to reset your password.
home.openweathermap.org
이 사이트를 통해 날씨 정보를 가져올 수 있음.
정상적으로 진행하다가 다음과 같은 에러가 발생
자세히 보니 401 에러. 즉 권한이 없다는 것.
나는 분명 api도 발급받고 이메일 컨펌까지 받았는데??
다른 여러 글들을 찾아보다가 해결법을 찾음
## 기존 코드 (공식 홈페이지에 나온 것)
https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&exclude={part}&appid={API key}
##해결 방안
`https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&appid=${API_KEY}&units=metric&lang=kr`
무슨 차이가 있는가 하니
다음과 같이 units 옵션을 추가해야 한다. 사용하지 않으면 기본적으로 standard 옵션을 사용하는데 이게 문제였던 거 같다. metric으로 사용할 경우 아주 잘 작동한다.
끗
'React & React Native' 카테고리의 다른 글
Framer Motion 속성 정리 (0) | 2024.07.02 |
---|---|
Bottom Sheet (React로 구현하기) (0) | 2024.05.06 |
Kakao Map Api 사용하기 (with React) (0) | 2024.03.14 |
React Modal (0) | 2024.02.08 |
styled-components의 스타일 상속 문제! (0) | 2024.02.03 |