카테고리 없음

[JavaScript] then 메소드

공기반 코딩반 2023. 5. 25. 09:21
반응형
console.log('START!');

fetch('https://jsonplaceholder.typicode.com/users')
  .then((response) => response.text())
  .then((result) => {console.log(result); })
  
console.log('END');

then 메소드

- Promise 객체가 fulfilled 상태가 되었을 때, 실행할 callback을 등록하는 메소드

- Promise 객체가 fulfilled 상태가 되면, 작업 성공 결과(서버가 보내 준 response)를 갖는 데 response이다.

 

 

→ fetch 함수는 Promise 객체 return -> fulfilled 상태가 되면 -> then 메소드 등록

 

 

반응형