Search code examples
javascriptreactjsproxystrapi

react fetch response meaning of type


While viewing the response using the fetch api in the react app created with create-react-app, the following output occurred.

screenshot

I don't get the meaning of type in response. I mean, what type?

Since react dev port and strapi port is different, I set proxy configuration in package.json

"proxy": "http://localhost:1337"

Source code is just a simple fetch request for other port that I'm using with strapi.

  useEffect(() => {
    (async () => {
      const result = await fetch(`${process.env.REACT_APP_API_HOST}/contents`, {
        headers: {},
      });
      console.log(result);
    })();
  }, []);

What is the meaning of type in this response?


Solution

  • Thanks to @decpk Who commented on my post, finally knew what it means. https://developer.mozilla.org/en-US/docs/Web/API/Response/type

    It literally means the type of response, and Since I used proxy option for request to cross-origin domain, the response type meant 'cors' is Response was received from a valid cross-origin request.