Skip to content

Commit

Permalink
Exclude content type header if multipart/form-data in fetch client (#…
Browse files Browse the repository at this point in the history
…1532)

* Exclude content type header if multipart/form-data

* Update packages/fetch/src/index.ts

Co-authored-by: Shodai Suzuki <[email protected]>

* Fix ignore content types clause

---------

Co-authored-by: Shodai Suzuki <[email protected]>
  • Loading branch information
jamesleeht and soartec-lab authored Jul 29, 2024
1 parent 31f2f94 commit 40f0613
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/fetch/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ ${
? `${stringify(override?.requestOptions)?.slice(1, -1)?.trim()}`
: '';
const fetchMethodOption = `method: '${verb.toUpperCase()}'`;
const fetchHeadersOption = body.contentType
? `headers: { 'Content-Type': '${body.contentType}' }`
: '';
const ignoreContentTypes = ['multipart/form-data'];
const fetchHeadersOption =
body.contentType && !ignoreContentTypes.includes(body.contentType)
? `headers: { 'Content-Type': '${body.contentType}' }`
: '';
const requestBodyParams = generateBodyOptions(
body,
isFormData,
Expand Down

0 comments on commit 40f0613

Please sign in to comment.