leebom
[02-08] 노마드코더 - momentum 만들기 본문
part 5 . getting the weather API
참고링크.
openweathermap.org/current#data
Current weather data - OpenWeatherMap
Access current weather data for any location on Earth including over 200,000 cities! We collect and process weather data from different sources such as global and local weather models, satellites, radars and vast network of weather stations. Data is availa
openweathermap.org
const API_KEY = "241051bf13976dd3ddf8b8d9f247255e";
const COORDS = "coords";
function getWeather(lat, lon) {
fetch(`https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&appid=${API_KEY }&units=metric`
).then(function(response){ //서버로부터 데이터가 들어올때까지 기다렸!!!!!
return response.json() //대기상태
}).then(function(json){
const temperature = json.main.temp;
const place = json.name;
weather.innerText = `${temperature} @ ${place}`;
})
}
(깃허브) 작업 주소 :
leebom21/basicjs
basic js. Contribute to leebom21/basicjs development by creating an account on GitHub.
github.com
'스터디 > 개인스터디(유투브 드림코딩 by엘리)(주5회)' 카테고리의 다른 글
[유투브 클론] #2 NODEJS 서버만들기 (0) | 2020.11.10 |
---|---|
[유투브 클론] #1 NODEJS THEORY (0) | 2020.11.06 |
[02-07] 노마드코더 - momentum 만들기 (0) | 2020.11.03 |
[02-06] 노마드코더 - momentum 만들기 (0) | 2020.11.02 |
[02-05] 노마드코더 - momentum 만들기 (0) | 2020.10.26 |
Comments