Web/JavaScripts

[JavaScripts] API 호출하기

usingsystem 2023. 4. 18. 10:39
728x90

json placeholder에 무료 API가 있다.

 

fetch를 사용해서 api를 호출할 수 있다. fatch는 promise를 return 한다.

async function getData() {
  let rawResponse = await fetch("https://jsonplaceholder.typicode.com/posts");
  let jsonResponse = await rawResponse.json();
  console.log(jsonResponse);
}

getData();

 

728x90