본문 바로가기

기타

weather 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 the global and local weather models, satellites, radars and a vast network of weather stations. how to obtain APIs (subscriptions w

openweathermap.org

위 사이트에 들어가서 회원가입 후 api를 받아온다.

 

fetch(url) 은 url로 request를 보내면 response 받는다.

 

fetch는 javaScript 내장 API로 비동기 통신 네트워크를 가능하게 해준다.

url로 요청을 보낸 결과로 Promise 객체를 반환한다.

XMLHttpRequest보다 훨씬 간단하고 간결하다.

 

fetch는 나중에 좀 더 자세하게 정리 해야겠따!

 

암튼 fetch 결과 아래처럼 promise 객체가 반환된다.

이를 이용해서 url을 주소창에 입력해보고 원하는 정보를 뽑아올 수 있다.

날씨와 위치를 얻어왔다.

console 창


https://openweathermap.org/weather-conditions

 

Weather Conditions - OpenWeatherMap

Weather Conditions Home Weather Conditions

openweathermap.org

 

'기타' 카테고리의 다른 글

[GitHub] Github page로 웹 호스팅  (0) 2024.07.03
[GitHub] Repository 이름 변경하기  (0) 2024.07.03
[ 수정중 ]Vuex란?!  (0) 2022.10.20
HTTP VS HTTPS  (0) 2022.10.13
스레드  (0) 2022.10.13