@@ -233,6 +233,10 @@ function isBlob(value: any): value is Blob {
233233 return value instanceof Blob;
234234}
235235
236+ function isFormData(value: any): value is FormData {
237+ return value instanceof FormData;
238+ }
239+
236240function base64(str: string): string {
237241 try {
238242 return btoa(str);
@@ -347,7 +351,7 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
347351 headers.append('Content-Type', options.body.type || 'application/octet-stream');
348352 } else if (isString(options.body)) {
349353 headers.append('Content-Type', 'text/plain');
350- } else {
354+ } else if (!isFormData(options.body)) {
351355 headers.append('Content-Type', 'application/json');
352356 }
353357 }
@@ -359,7 +363,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
359363 if (options.body) {
360364 if (options.mediaType?.includes('/json')) {
361365 return JSON.stringify(options.body)
362- } else if (isString(options.body) || isBlob(options.body)) {
366+ } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body) ) {
363367 return options.body;
364368 } else {
365369 return JSON.stringify(options.body);
@@ -2896,6 +2900,10 @@ function isBlob(value: any): value is Blob {
28962900 return value instanceof Blob;
28972901}
28982902
2903+ function isFormData(value: any): value is FormData {
2904+ return value instanceof FormData;
2905+ }
2906+
28992907function base64(str: string): string {
29002908 try {
29012909 return btoa(str);
@@ -3010,7 +3018,7 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
30103018 headers.append('Content-Type', options.body.type || 'application/octet-stream');
30113019 } else if (isString(options.body)) {
30123020 headers.append('Content-Type', 'text/plain');
3013- } else {
3021+ } else if (!isFormData(options.body)) {
30143022 headers.append('Content-Type', 'application/json');
30153023 }
30163024 }
@@ -3022,7 +3030,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
30223030 if (options.body) {
30233031 if (options.mediaType?.includes('/json')) {
30243032 return JSON.stringify(options.body)
3025- } else if (isString(options.body) || isBlob(options.body)) {
3033+ } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body) ) {
30263034 return options.body;
30273035 } else {
30283036 return JSON.stringify(options.body);
0 commit comments