목록NomadCoder/TodoJS (1)
도룩이의 개발일기
API를 이용하여 날씨정보 보여주기( weather.js )
weather.js openweathermap.org에서 weather API KEY를 받아야 함. then은 이전 자바스크립트 코드가 완전히 실행돼서 데이터가 완전히 넘어왔을 때만 실행된다. 만약, 여기서 then을 쓰지 않으면, 아직 API 데이터가 넘어오지 않았는데 실행되어 에러가 날 수 있음! const weather = document.querySelector(".js-weather"); const API_KEY = "38cb84355b7ad3bb3676b3b9e6b11d39"; const COORDS = "coords"; // 여기서 fetch 함수는 requests 함수와 같은 역할. function getWeather(lat, lng){ fetch( `https://api.openweath..
NomadCoder/TodoJS
2020. 12. 1. 01:26