Information*/알면도움됨

Weather API 가 필요할 때

ch4rli3kop 2019. 3. 8. 00:13
반응형

OpenWeatherMap

날씨 정보가 필요할 경우 유용하게 사용할 수 있는 곳이다. API를 통해, 지역의 날씨 정보를 JSON, XML, HTML format으로 받을 수 있다. (무료, 회원가입 필요) https://openweathermap.org/

  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}`;
});

활용한다면 위처럼 사용할 수 있고, request에 대한 response의 예시는 다음과 같다.


반응형

'Information* > 알면도움됨' 카테고리의 다른 글

zip2john 설치  (0) 2019.03.13
PIL과 Pillow  (0) 2019.03.11
색 찾을 때 유용한 사이트  (0) 2019.03.07
Atom syntax theme 잘 적용이 안될 때  (0) 2019.02.25
Visual Studio Code 환경 세팅  (0) 2019.02.13