Geolocation

김민재·2021년 7월 2일
0

Gotcha JavaScript!

목록 보기
12/45

navigator.geolocation.getCurrentPosistion(성공시 함수, 실패시 함수)

<script>
function onGeoOk(position){
  const latitude = position.coords.latitude;
  const longitude = position.coords.longitude;
console.log("You live in",  latitude , longitude)

}
function onGeoError(){
 alert("error")
}

navigator.geolocation.getCurrentPosition(onGeoOk, onGeoError);
</script>

Geolocation

weather API를 통해서 현재 날씨를 받아온다.

fetch를 사용해서 url을 얻는다.

profile
자기 신뢰의 힘을 믿고 실천하는 개발자가 되고자합니다.

0개의 댓글