Skip to content

Commit 5a0548a

Browse files
Hotfix/response type blob (#3)
* update-response-type-for-blob-data * update-blob-response-type-for-node-fetch-module * revert-last-commit-unnecessary-changes
1 parent 866f8ef commit 5a0548a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/templates/core/fetch/getResponseBody.hbs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@ async function getResponseBody(response: Response): Promise<any> {
22
try {
33
const contentType = response.headers.get('Content-Type');
44
if (contentType) {
5-
const isJSON = contentType.toLowerCase().startsWith('application/json');
5+
6+
const jsonTypes = ['application/json', 'application/problem+json']
7+
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
8+
9+
//Check for the blob types
10+
const blobTypes = ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
11+
const isBlob = blobTypes.some(type => contentType.toLowerCase().startsWith(type));
12+
613
if (isJSON) {
7-
return await response.json();
14+
return await response.json();
15+
} else if (isBlob) {
16+
return await response.arrayBuffer();
817
} else {
918
return await response.text();
1019
}

0 commit comments

Comments
 (0)