Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
¿Cómo mostrar la imagen de la cuenta binaria recibida de la API gráfica de msal?

Puedo consultar la API del gráfico msal usando https://graph.microsoft.com/v1.0/me/photo/$value pero una vez que tengo la respuesta, que según [la documentación][1] es un valor binario, no puedo mostrar esto en mi aplicación Vue. Intenté usar createObjectURL para hacer un blob y configurarlo como el atributo src del elemento img de esta manera:

 const url = window.URL || window.webkitURL; const blobUrl = url.createObjectURL(response.data); document.getElementById("imageElement").setAttribute("src", blobUrl);

pero me sale el error:

TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.

Estoy obteniendo la imagen como esta:

 axios.get("https://graph.microsoft.com/v1.0/me/photos/48x48/$value", { headers: { Authorization: "Bearer " + "xxxxxxx" // this is the auth token } }) .then(response => { const url = window.URL || window.webkitURL; const blobUrl = url.createObjectURL(response.data); document.getElementById("imageElement").setAttribute("src", blobUrl); }); ``` [1]: https://docs.microsoft.com/en-us/graph/api/profilephoto-get?view=graph-rest-1.0
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Prueba esto.

 yourImg.src = 'data:image/jpeg;base64, ' + Buffer.from(response.data, 'binary').toString('base64');

También revisa las respuestas y comentarios aquí .

about 4 years ago · Juan Pablo Isaza Report

0

Debe llamar a blob() en la respuesta: vea este ejemplo

 fetch("https://random.imagecdn.app/500/500").then(async response => { const url = window.URL || window.webkitURL; const blobUrl = url.createObjectURL(await response.blob()); document.getElementById("imageElement").setAttribute("src", blobUrl); });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!