반응형
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 메소드 등록
반응형