@@ -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);
@@ -2933,6 +2937,10 @@ function isBlob(value: any): value is Blob {
29332937 return value instanceof Blob;
29342938}
29352939
2940+ function isFormData(value: any): value is FormData {
2941+ return value instanceof FormData;
2942+ }
2943+
29362944function base64(str: string): string {
29372945 try {
29382946 return btoa(str);
@@ -3047,7 +3055,7 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
30473055 headers.append('Content-Type', options.body.type || 'application/octet-stream');
30483056 } else if (isString(options.body)) {
30493057 headers.append('Content-Type', 'text/plain');
3050- } else {
3058+ } else if (!isFormData(options.body)) {
30513059 headers.append('Content-Type', 'application/json');
30523060 }
30533061 }
@@ -3059,7 +3067,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
30593067 if (options.body) {
30603068 if (options.mediaType?.includes('/json')) {
30613069 return JSON.stringify(options.body)
3062- } else if (isString(options.body) || isBlob(options.body)) {
3070+ } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body) ) {
30633071 return options.body;
30643072 } else {
30653073 return JSON.stringify(options.body);
0 commit comments