사용자의 현재 위치를 가져오는 API
navigator.geolocation.getCurrentPosition(success, error, options);
GeolocationPosition 객체를 유일한 매개변수로 받는 콜백함수GeolocationPositionError 객체를 유일한 매개변수로 받는 콜백함수GeolocationPosition 인터페이스: 주어진 시간에 장치가 위치한 지점을 나타냄.Position.coords: 주어진 시간의 위치Position.coords.latitude / Position.coords.longitude 등Position.timestamp: 위치를 기록한 시간GeolocationPositionError: 에러 발생 이유를 나타냄Error.code / Error.messageAPI call by geographic coordinates! (lat, lon, API_KEY)
원격 API를 간편하게 호출할 수 있도록 브라우저에서 제공하는 함수!
URL, 두 번째 인자로 옵션 객체를 받고 Promise 객체를 반환한다.response)를 resolve하고, 실패했을 경우 예외 객체(error)를 reject한다.fetch(url)
.then(response => response.json())
.then(data => console.log(data));
response.json(): 응답 객체로부터 JSON 포맷의 응답 전문을 자바스크립트 객체로 변환하여 얻을 수 있다.