openweather api 호출 했는데 401가 나요!
Viết
·
1.3K
0
const getCurrentLocation = () => {
navigator.geolocation.getCurrentPosition((position)=>{
console.log('위치', position.coords.latitude, position.coords.longitude); // 위치 37.4838677 126.902839
getWeatherByCurrentLocation(position.coords.latitude, position.coords.longitude);
});
}
const getWeatherByCurrentLocation = async(latitude, longitude) => {
let apiKey = '0619cf6a981bec8d01375e5576139e86';
let apiUrl = `https://api.openweathermap.org/data/3.0/onecall?lat=${latitude}&lon=${longitude}&appid=${apiKey}`;
let response = await fetch(apiUrl);
let data = await response.json();
console.log('data', data);
}
useEffect(()=>{getCurrentLocation()}, []);이렇게 작성해서 돌려보니
이런식으로 401에러가 납니다....원인을 잘 모르겠어요!ㅠㅠ
reactreduxweb-api
Quiz
46% người trả lời sai. Hãy thử ngay!
React 애플리케이션에서 부모 컴포넌트가 자식 컴포넌트로 데이터를 전달하는 주된 방법은 무엇일까요?
State를 이용해 자식에서 부모로 직접 전달
Props를 이용해 부모에서 자식으로 전달
Context API를 이용한 양방향 전달
Ref를 이용한 형제 간 전달
Câu trả lời 1
0
codingnuna10082706
Người chia sẻ kiến thức
안녕하세요 3.0 버전은 유료버전이거나 따로 api를 발급받아야하는 것 같네요 2.5버전을 호출 부탁드립니다!
https://api.openweathermap.org/data/2.5/weather
추가 질문은 제 슬랙채널에서 해주세요!
https://join.slack.com/t/w1631756876-zfv299364/shared_invite/zt-w5yxap8g-~_Exi5lOwfw_N6a1T5djmg





