Skip to content

postForm fails with "source.on is not a function" when using Buffer or Uint8Array in Node 18 #4727

@smares

Description

@smares

Describe the issue

Passing Uint8Array or Buffer to postForm results in "source.on is not a function" exception.

Example Code

const data = Uint8Array.from([1, 2, 3])
axios.postForm('http://some.url', { data })

// or

const data = Uint8Array.from([1, 2, 3])
axios.postForm('http://some.url', { data: Buffer.from(data) })

Expected behavior, if applicable

axios should POST a field "data" with the content of the Uint8Array / Buffer

Environment

  • Axios Version 0.27.2
  • Node.js Version 18.2.0
  • OS: Windows 11

Additional context/Screenshots

Code is compiled from TypeScript using typescript 4.6.4 and a tsconfig.json that extends @tsconfig/node18/tsconfig.json

I am trying to upload the PDF output of puppeteer.

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions