해결됨
[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스
오픈웨더 api 관련 문제가 생겼습니다
// 오픈웨더 API
const weatherSearch = function(position) {
console.log(position.latitude);
const openWeatherRes = fetch(
`https://api.openweathermap.org/data/2.5/onecall?lat=${position.latitude}&lon=${position.longitude}&appid=a0fe4b649d353a27a301be4b66d4173c`
);
console.log(openWeatherRes);
// 구분
};
// 현재 위치 함수
const accessToGeo = function (position) {
const positionObj = {
latitude : position.coords.latitude,
longitude : position.coords.longitude,
};
weatherSearch(positionObj);
};
// 사용자 현재 위치
const askForLocation = function (){
navigator.geolocation.getCurrentPosition(accessToGeo, (err) =>{
console.log(err);
} );
};
;
askForLocation();
현재 코드가 이렇게 되는데 401 오류가 뜨고 있습니다 // 오픈웨더 API
const weatherSearch = function(position) {
console.log(position.latitude);
const openWeatherRes = fetch(
`https://api.openweathermap.org/data/2.5/onecall?lat=${position.latitude}&lon=${position.longitude}&appid=a0fe4b649d353a27a301be4b66d4173c`
);
console.log(openWeatherRes);
// 구분
};해당 코드에서 $ 부분이 오류가 뜨고 있기도 한데... api는 default를 사용하였습니다 몇시간 강의 다시 보면서 뭐 잘못된 거 있나 해봐도 안 되서 이렇게 글 올려봐요콘솔창 에러 메시지입니다