Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

"type:cors, status: 200 ok" response from graph endpoint #33

Closed
1 task done
Eli-Schei opened this issue Nov 11, 2021 · 2 comments
Closed
1 task done

"type:cors, status: 200 ok" response from graph endpoint #33

Eli-Schei opened this issue Nov 11, 2021 · 2 comments
Labels
question Further information is requested

Comments

@Eli-Schei
Copy link

Please follow the issue template below. Failure to do so will result in a delay in answering your question.

Library

  • msal@2.x.x or @azure/msal@2.x.x

Description

The loginpopup call works fine and I can log in and get a accesstoken that I have tested in postman, and the token works fine as well. My problem is that when I make a call to graph like described in this tutorial I get an cors response from graph.
In the network tab the request is displayed as "200 OK"
image

But the object that is returned is of type "cors"
image

I copied the function from this tutorial.

.....
    fetch(endpoint, options)
      .then((response) => {
        console.log(response);  //This is the response that is "type: cors" from image above
      })
      .then((response) => callback(response, endpoint)) //Here the response is null/undefined
      .catch((error) => console.log(error));
  }

It is a SPA that I have registered in Azure AD like described here: https://docs.microsoft.com/en-us/graph/tutorials/javascript?tutorial-step=2
Maybe I have to do some more configuration to avoid the cors response??

@Eli-Schei Eli-Schei added the question Further information is requested label Nov 11, 2021
@derisen
Copy link
Contributor

derisen commented May 2, 2022

Hi @Eli-Schei, apologies for the (very) late response. It seems you're not parsing the response you get in the first then clause as JSON, so that must be the issue:

    fetch(endpoint, options)
      .then((response) => {
        const responseInJson = response.json(); // parse the response
        console.log(responseInJson);
        return responseInJson; // don't forget to return it
      })
      .then((response) => callback(response, endpoint)) //Here the response is null/undefined
      .catch((error) => console.log(error));
  }

Let me know if that doesn't resolve your issue. Again, sorry this went unattended for so long.

@derisen
Copy link
Contributor

derisen commented May 10, 2022

Closing this due to inactivity. Let us know if you have a further issue.

@derisen derisen closed this as completed May 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants