mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
fix(getRequestBody): options.bodyMediaType can be undefined
This commit is contained in:
parent
2eb3529d63
commit
ea7f26b0e9
@ -3,7 +3,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
|
||||
return getFormData(options.formData);
|
||||
}
|
||||
if (options.body) {
|
||||
if (options.bodyMediaType.includes('/json')) {
|
||||
if (options.bodyMediaType?.includes('/json')) {
|
||||
return JSON.stringify(options.body)
|
||||
} else if (isString(options.body) || isBlob(options.body)) {
|
||||
return options.body;
|
||||
|
||||
@ -3,9 +3,9 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
|
||||
return getFormData(options.formData);
|
||||
}
|
||||
if (options.body) {
|
||||
if (options.bodyMediaType.includes('/json')) {
|
||||
if (options.bodyMediaType?.includes('/json')) {
|
||||
return JSON.stringify(options.body)
|
||||
} else if (isString(options.body) || isBlob(options.body)) {
|
||||
} else if (isString(options.body) || isBinary(options.body)) {
|
||||
return options.body;
|
||||
} else {
|
||||
return JSON.stringify(options.body);
|
||||
|
||||
@ -3,7 +3,7 @@ function getRequestBody(options: ApiRequestOptions): any {
|
||||
return getFormData(options.formData);
|
||||
}
|
||||
if (options.body) {
|
||||
if (options.bodyMediaType.includes('/json')) {
|
||||
if (options.bodyMediaType?.includes('/json')) {
|
||||
return JSON.stringify(options.body)
|
||||
} else if (isString(options.body) || isBlob(options.body)) {
|
||||
return options.body;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user