Skip to content

Commit 7bf9ed1

Browse files
committed
Update getResponseBody.hbs
Make it possible to return blob type.
1 parent 2a8690c commit 7bf9ed1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/templates/core/node/getResponseBody.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ async function getResponseBody(response: Response): Promise<any> {
33
const contentType = response.headers.get('Content-Type');
44
if (contentType) {
55
const isJSON = contentType.toLowerCase().startsWith('application/json');
6+
const isBlob = contentType.toLowerCase().startsWith('image/')
7+
|| contentType.toLowerCase().startsWith('application/pdf')
8+
|| contentType.toLowerCase().startsWith('application/zip');
69
if (isJSON) {
7-
return await response.json();
10+
return await response.json();
11+
} else if (isBlob) {
12+
return await response.blob();
813
} else {
914
return await response.text();
1015
}

0 commit comments

Comments
 (0)