Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch 사용시 프로토타입 체인 질문 #79

Open
gymdong opened this issue Mar 19, 2022 · 0 comments
Open

fetch 사용시 프로토타입 체인 질문 #79

gymdong opened this issue Mar 19, 2022 · 0 comments
Labels
question Further information is requested

Comments

@gymdong
Copy link
Contributor

gymdong commented Mar 19, 2022

const getDataFromBackend = async () => {
    const rest = await fetch("http://localhost:8000/users");
    console.log(rest); //Response 객체를 래핑한 Promise 객체
    console.log(rest instanceof Promise); // 왜 false? Response 하면 True.
    const data = await rest.json();
    console.log(data); //Data 
    return data;
  };

이 예제는 fetch를 이용해 rest 변수에 Response 객체를 래핑한 Promise 객체를 할당하는 예제인데요,
console.log(rest instanceof Promise); 를 실행하면 false가 나옵니다.
그렇지만 rest instanceof Response를 하면 true가 나오는데, 프로토타입 관점에서 Promise와 Response가 어떻게 다른지 궁금합니다.

@gymdong gymdong added the question Further information is requested label Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant