Skip to content

Commit ea7f26b

Browse files
committed
fix(getRequestBody): options.bodyMediaType can be undefined
1 parent 2eb3529 commit ea7f26b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/templates/core/fetch/getRequestBody.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
33
return getFormData(options.formData);
44
}
55
if (options.body) {
6-
if (options.bodyMediaType.includes('/json')) {
6+
if (options.bodyMediaType?.includes('/json')) {
77
return JSON.stringify(options.body)
88
} else if (isString(options.body) || isBlob(options.body)) {
99
return options.body;

src/templates/core/node/getRequestBody.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
33
return getFormData(options.formData);
44
}
55
if (options.body) {
6-
if (options.bodyMediaType.includes('/json')) {
6+
if (options.bodyMediaType?.includes('/json')) {
77
return JSON.stringify(options.body)
8-
} else if (isString(options.body) || isBlob(options.body)) {
8+
} else if (isString(options.body) || isBinary(options.body)) {
99
return options.body;
1010
} else {
1111
return JSON.stringify(options.body);

src/templates/core/xhr/getRequestBody.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function getRequestBody(options: ApiRequestOptions): any {
33
return getFormData(options.formData);
44
}
55
if (options.body) {
6-
if (options.bodyMediaType.includes('/json')) {
6+
if (options.bodyMediaType?.includes('/json')) {
77
return JSON.stringify(options.body)
88
} else if (isString(options.body) || isBlob(options.body)) {
99
return options.body;

0 commit comments

Comments
 (0)