커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
Fetch 연습하기
코딩이 처음이어도 쉽게 배우는 웹개발 A to Z
챕터 3
북마크
백*민
댓글
8
추천
0
조회수
21
조회수
21
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


url 연결부터 console페이지에서 에러가 떠요

학습자료에서 완성된 코드를 복사-붙여넣기해도 똑같은 오류가 뜨고 사파리페이지에서도 동일해요


스파르타 즉문즉답






<!doctype html>

<html lang="ko">


<head>

  <meta charset="UTF-8">

  <title>Fetch 시작하기</title>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

  <script>

    function hey() {

      let url = 'https://13.209.69.177.nip.io/sparta_api/seoulair';

      fetch(url).then(res => res.json()).then(data => {

        console.log(data['RealtimeCityAir']['row'][0])

      })

    }

  </script>

</head>


<body>

  <button onclick="hey()">fetch 연습!</button>

</body>


</html>



에러메세지

VM224:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<?xml vers"... is not valid JSON

VM256:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<?xml vers"... is not valid JSON




취소
 공유
취소
댓글 0
댓글 알림
나의얼굴