Fetch API

  • Fetch API 의 가장 유용하고, 핵심적인 함수는 fetch() 함수
  • 가장 간단한 형태의 fetch() 함수는 URL 을 인자로 받고 응답을 처리하기 위한 promise를 반환.
  • 응답을 처리할 때 Response 객체를 이용 할 수 있다
fetch(endpoint)
    .then(blob => blob.json())
    .then(data => cities.push(...data));

code & view

출처 : [javascript30.com] 30 Day Vanilla JS Coding Challenge