0👍
Explanation:
-
In below snippet as you can see I am passing the
objectId
of the Employee fetched from Graph previously.
-
Then making call for employee to get their Avatar/DP
-
The Graph Profile Photo endpoint returns binary Data of the photo.
-
Convert that binary data into
data:image/png;base64,<readAsDataURL>
URL e.g.data:image/png;base64,iVBORw0KGgoAAAANSU...
-
Use in
<img src="dataUrl"/>
let imageUrl = (await request.get(GRAPH_CONFIG.GRAPH_DP_ENDPT + objectId + "/photos/48x48/\$value", { responseType: 'arraybuffer', validateStatus: (status) => status === 200 || status === 404 })) if (imageUrl.status === 200) { let reader = new FileReader() let blob = new Blob([imageUrl.data], {type: 'image/jpeg'}) reader.onload = (event) => { return event.target?.result.toString(); } reader.readAsDataURL(blob) }
- [Vuejs]-How to return the Id of the database and not a Default Id in VUE?
- [Vuejs]-How get response in axios when api is steam like SSE (Server-Send Events)
Source:stackexchange.com