Skip to content

NotSupportedError: multipart/form-data not supported #1979

@kettanaito

Description

@kettanaito

Bug Description

Getting the following error:

 Promise {
      <rejected> NotSupportedError: multipart/form-data not supported
          at Request.formData (node:internal/deps/undici/undici:2311:19)

Reproducible By

const formData = new FormData()
formData.append('username', 'john.maverick')

const req = new Request('http://localhost', {
  method: 'POST',
  body: formData,
})

console.log(req.formData())

This example uses Node.js globals for Fetch API so I'm not importing any polyfills for neither Request nor FormData.

Expected Behavior

Calling request.formData() must return a Promise that resolves to a FormData instance containing the fields initially supplied to the Request constructor.

Logs & Screenshots

Environment

  • Node 18.8.0

Additional context

I've skimmed Undici's source and couldn't find this NotSupportedError instance. I suspect this was indeed unsupported in the past but has been implemented in the newer versions of Node? I'd like to know when this was added, if ever. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions