AJAX1 api fetch() 써보기 오픈 서버로 부터 정보를 받아와서 데이터를 확인 할 수 있다. 구글링으로 free open api치면 많이 나온다. fetch()를 사용하여 get방식으로 서버의 정보를 가져오며, async await 방법을 사용하여 데이터 정보를 받아온다. const url = "http://worldtimeapi.org/api/timezone/Asia/Seoul"; async function getData(){ const response = await fetch(url); const data = await response.json(); console.log(data) } 이때 , async - await 문법은 promise를 간소화한 문법이다. 저걸 원래 promise문법으로 쓴다면 , function getDat.. 2023. 3. 11. 이전 1 다음