С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
사이트 들어가서 회원가입 후 오른쪽 상단의 내 프로필을 누른 뒤 My API keys 클릭

Key에 적혀 있는 값을 메모장이나 .env에 복사해 둔 뒤.
상단의 API누르고,

Current Weather Data - API doc 클릭!

API call 부분도 복사후 저장!.
그리고 Current weather data Api call 복사부분 뒤에
이거 붙여 넣으면 섭씨 온도로 바뀌어서 날씨 측정해줍니다.
그리고
출처 : https://stackoverflow.com/questions/12460378/how-to-get-json-from-url-in-javascript
How to get JSON from URL in JavaScript?
This URL returns JSON: { query: { count: 1, created: "2015-12-09T17:12:09Z", lang: "en-US", diagnostics: {}, ... } } I tried this, and it didn't work: responseObj =
stackoverflow.com
stackoverflow 에서 Json 받아오는 코드를 찾았고,
Current weather data에 자기 API 삽입후
코드를 실행시키고, 웹사이트 console 창을 보시면
날씨는
온도는 7.01°
풍속은 3.09m/s
습도는 63%
입니다.
오늘의
최고기온은 8.12°
최저기온은 5.42°
입니다.
이렇게 나옵니다.
'it > nestjs' 카테고리의 다른 글
Nest.JS MQTT 통신 브로커 연결 (2) | 2023.05.03 |
---|---|
Next.js( react-slick ) (1) | 2023.03.23 |
JWT 순서 (3) | 2023.02.16 |
JWT Token (0) | 2023.02.02 |
Nest.js 구글 로그인(1) (1) | 2023.01.11 |
댓글