Information*/알면도움됨
Weather API 가 필요할 때
ch4rli3kop
2019. 3. 8. 00:13
반응형
날씨 정보가 필요할 경우 유용하게 사용할 수 있는 곳이다.
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의 예시는 다음과 같다.
반응형