
fetch는 비동기 방식으로 서버에 request를 보내고, 서버로부터 response를 받는 함수이다
then 메소드는 response가 왔을 때 등록된 콜백 함수를 실행한다
ex) fetch와 then을 사용하여 response 값을 출력하는 코드이다
fetch('https://www.google.com')
.then((response) => response.text())
.then((result) => { console.log(result); });
Promise 객체는 fetch 함수와 then 메소드가 리턴하는 객체이다
fetch('https://first.com', (response) => {
// Do Something
fetch('https://second.com', (response) => {
// Do Something
fetch('https;//third.com', (response) => {
// Do Something
fetch('https;//fourth.com', (response) => {
// Do Something
});
});
});
});