Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

123
Visualizações
can't fetch msgraph data using vanilla js

I am trying to pull data from the endpoint https://graph.microsoft.com/v1.0/me/. I have done this using python but I can't seem to fetch data from Microsoft Graph using vanilla js.

When I attempt to perform a fetch request. I get a 200 response but nothing is inside the response object.

Here is the fetch code:

fetch("https://graph.microsoft.com/v1.0/me/", {
  method: "GET",
  "headers": {
    "authorization": "Bearer ENTERTOKENHERE"}
}).then(data =>{console.log(data)});

I get a response of:

Response {type: 'cors', url: 'https://graph.microsoft.com/v1.0/me/', redirected: false, status: 200, ok: true, …}

but I am expecting more of a response like the one I get from the https://developer.microsoft.com/en-us/graph/graph-explorer website like this:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
    "businessPhones": [],
    "displayName": "Edd Bighead",
    "givenName": "Edd",
    "jobTitle": null,
    "mail": "Edd@conglomo.onmicrosoft.com",
    "mobilePhone": null,
    "officeLocation": null,
    "preferredLanguage": "en-US",
    "surname": "Bighead",
    "userPrincipalName": "Edd@conglomo.com",
    "id": "2fa321d9-bda3-41c1-8be8-5d4049ed8765"
}

Is there anything I am missing to get the data from msgraph using vanilla js only?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I figured it out - I needed to jsonize the data then print that data. Can't believe I missed that. lol

fetch("https://graph.microsoft.com/v1.0/me/", {
  method: "GET",
  "headers": {
    "authorization": "Bearer ENTERTOKENHERE"}
}).then(response => response.json())
.then(data => {console.log(data)})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda