Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FormData Node.js v18 #330

Closed
RemyMachado opened this issue Nov 26, 2022 · 6 comments · Fixed by #346
Closed

Support FormData Node.js v18 #330

RemyMachado opened this issue Nov 26, 2022 · 6 comments · Fixed by #346

Comments

@RemyMachado
Copy link

RemyMachado commented Nov 26, 2022

Since Node.js v18, FormData is part of the native Node.js' API:

image

Unfortunately mailgun.js doesn't support it yet. Furthermore the recommended form-data library is unmaintained and not a good alternative.

@RomainJamet
Copy link

Worse, even: mailgun.js supports an older version of form-data apparently. Following issue to update my code when possible.

@jimmywarting
Copy link

jimmywarting commented Dec 6, 2022

I recommend that you switch out axios for a fetch api. either provided by node-fetch, undici or built in. that supports encoding a spec'ed FormData. You can later remove the dependency of them when the time comes when you only support nodejs v18+

@olexandr-mazepa
Copy link
Collaborator

Hi RemyMachado
Currently, Axios isn't compatible with FormData implemented in node 18.
I don't want to switch to another package because I believe this issue will be fixed in Axios soon.

Here is a related issue in the Axios library that may be used for tracking:
axios/axios#5327

@jimmywarting
Copy link

I don't want to switch to another package

Why do you prefer a axios dependency over built in fetch that is supported in a variant different engines (web worker, node, deno, bun)?

@olexandr-mazepa
Copy link
Collaborator

There are a few reasons:

  • First one. Fetch API was added to the node.js started only from v17(experimental support). I still have been trying to make this package available from node 12.
  • The second one is this comparison article https://www.geeksforgeeks.org/difference-between-fetch-and-axios-js-for-making-http-requests/ . A few items from the table at the bottom are bothering me(built-in XSRF protection, name of body property, stringifying of a data object, canceling the request, etc.).
  • The third one is that I recently moved from ky to Axios, and don't want to repeat this experience =)

Of course, they won't stop me if node 18 support in Axios takes too much time but in this particular case, I would rather wait some time. Axios will need to implement compatibility with node 18 anyway, and it seems there is a PR already that should fix the issue with form data.

@sidvishnoi
Copy link

@olexandr-mazepa PR for axios/axios#5327 is merged now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants