hoony's web study

728x90
반응형


오늘은 nodejs 에서 접속한 곳의 온도와 날씨를 받을 수 있는 방법을 알려드립니다.
위의 주소에 API를 신청하시구요. 

위의 주소는 : https://openweathermap.org/

 

Сurrent weather and forecast - OpenWeatherMap

Access current weather data for any location on Earth including over 200,000 cities! The data is frequently updated based on global and local weather models, satellites, radars and vast network of weather stations. how to obtain APIs (subscriptions with di

openweathermap.org

api.openweathermap.org/data/2.5/weather?q={city name}&appid={API key}

 

 axios.get('http://api.openweathermap.org/data/2.5/weather?q=도시&appid=apiKey').then(res=>{
          console.log('axios 도시 : '+res.data);
          console.log('axios 날씨 : '+res.data.weather[0].main);
          console.log('temp' + (res.data.main.temp -272).toString().substr(0,3));
          console.log('humidity' + res.data.main.humidity);
      });

 

728x90

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading