msgraph-sdk-javascript
msgraph-sdk-javascript copied to clipboard
Batching - Node
The documentation on batching makes use of the Browser's Request object.
How can the same thing be done in Nodejs?
It's very similar to what we do for the browser. Example:
async function testfunc()
{
try{
let photoRequest = new Request('/me/photo/$value', {
method: 'GET'
});
let meRequest = new Request('/me', {
method: 'GET'
});
let batchRequestContent = new MicrosoftGraph.BatchRequestContent([
{
request: photoRequest,
id: '1'
},
{
request: meRequest,
id: '2'
}
]);
let content = await batchRequestContent.getContent();
let response = await client
.api('$batch')
.post(content);
let batchResponse = new MicrosoftGraph.BatchResponseContent(response);
let responses = batchResponse.getResponses();
let me = await responses.get('2').json();
//let me = response.responses[0].body
}
catch(e)
{
console.log(e);
}
}
testfunc();
Closing this issue, for now. Feel free to open the issue, if needed.