Skip to content

Commit

Permalink
Merge pull request #3052 from RoelVB/fix/optional-headers-in-batch
Browse files Browse the repository at this point in the history
fixing content-type header bug in 204 response parsing
  • Loading branch information
juliemturner authored Jun 5, 2024
2 parents f38b4e1 + 2e8d567 commit e8acebb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/graph/batching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ function parseResponse(graphResponse: IGraphBatchResponse): ParsedGraphResponse
// we create the request id by adding 1 to the index, so we place the response by subtracting one to match
// the array of requests and make it easier to map them by index
const responseId = parseInt(response.id, 10) - 1;
const contentType = response.headers["Content-Type"];
const { status, statusText, headers, body } = response;
const init = { status, statusText, headers };

Expand All @@ -395,7 +394,7 @@ function parseResponse(graphResponse: IGraphBatchResponse): ParsedGraphResponse
// eslint-disable-next-line @typescript-eslint/dot-notation
parsedResponses[responseId] = new Response(jsS({ location: headers["Location"] || "" }), init);

} else if (status === 200 && /^image[\\|/]/i.test(contentType)) {
} else if (status === 200 && /^image[\\|/]/i.test(headers["Content-Type"] || "")) {

// this handles the case where image content is returned as base 64 data in the batch body, such as /me/photos/$value (https://github.com/pnp/pnpjs/issues/2825)

Expand Down

0 comments on commit e8acebb

Please sign in to comment.