-
[JS] 날씨 API 호출하기a 2022. 3. 25. 10:52반응형
Сurrent weather and forecast - OpenWeatherMap
Leaving everything behind, people are fleeing conflict in Ukraine. They need shelter, food, and water. When you subscribe to our service, you can join us to help with donation of just of 20. Openweather will add 40 to each donation and send it to Disastrou
openweathermap.org
날씨 정보를 알 수 있는 api를 호출해서 사용자 위치의 현재 날씨를 알려줄 수 있다.
위의 사이트에서 회원 가입을 한 후,
current weather api doc을 들어가면 다음과 같이 API call url이 있다.
이걸 복사한다.
https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}
bracket으로 묶인 변수가 세 개가 있다.
lat, lon은 navigator.geolocation.getCurrentPosition(); 함수를 호출해서 구할 수 있다.
그리고 API 키를 복사해서 마찬가지로 넣어 주고 JS 코드에서 사용하면 된다.
반응형'a' 카테고리의 다른 글
[c++] C언어와 C++의 다른 부분(bool, 참조자, new/delete) (4) 2022.03.30 [GPU] GPGPU-sssim ispass benchmark build (0) 2022.03.25 [알고리즘] 그리디 알고리즘 (0) 2022.03.24 [JS] localstorage (0) 2022.03.22 [JS] querySelector (0) 2022.03.22