Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async execute(): Promise {
const responses = {};
if (!this.requests.size) {
return responses;
}
const batchRequestContent = new BatchRequestContent();
for (const request of this.requests) {
batchRequestContent.addRequest({
id: request[0],
request: new Request(Batch.baseUrl + request[1].resource, {
method: request[1].method
})
});
}
let batchRequest = this.client.api('$batch').version('beta');
if (this.scopes.length) {
batchRequest = batchRequest.middlewareOptions(prepScopes(...this.scopes));
}
const batchResponse = await batchRequest.post(await batchRequestContent.getContent());
for (const response of batchResponse.responses) {
if (response.status !== 200) {
response[response.id] = null;