코딩/API 3

날씨 가져오기 Openweather

https://openweathermap.org/ Сurrent weather and forecast - OpenWeatherMap OpenWeather Weather forecasts, nowcasts and history in a fast and elegant way openweathermap.org 가입 하고 API키를 받는다. API탭에 원하는 기능별 API doc이 있는데, 보통 현재 날씨데이터를 요청하므로 Current Weather Data의 API doc의 링크를 남긴다. https://openweathermap.org/current Current weather data - OpenWeatherMap openweathermap.org 보면 API call에 요청하는 주소와 내용이 나와있다...

코딩/API 2024.03.31

위치 정보 가져오기 Geolocation

const geolocation = () => { navigator.geolocation.getCurrentPosition( (성공) => 성공, (실패) => 실패 ); }; 예시 코드를 이러며, 성공에는 latitude와 longtitude가 담겨있고, 실패에는 error의 code와 설명인 message가 담겨온다. 근데 이게 바로 응답이 오는게 아니라 좀 기다려야하다 보니 다른데서 이를 가져다 활용하려면 Promise로 만들어서 await을 해줘야한다. export const getLocation = async () => { return new Promise((resolve, reject) => { navigator.geolocation.getCurrentPosition( (position) =>..

코딩/API 2024.03.31