node-fetch / node-fetch Public
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
fix(Body): Discourage form-data and buffer() #1212
Conversation
Since node-fetch v3 bumps a major version, it would make sense to just remove things before a stable version ships if need be. |
I'm fine with removing form-data and buffer right now before shipping v3 if anyone else agree |
I think that removing of the form-data package right away will have a huge impact and broke code for many developers. Perhaps it would be preferable to have some transition period before its support will be gone for good. |
Where thinking quite the same thing when i made this PR. plans for v4 could be:
It would give them time to prepare |
In which case, we could implement new features and deprecate old ones in v3 and remove them in v4. |
@gr2m can you review this also? |
@kandaris this only shows how you are handling the response, now how you use the form-data package.
dos i would recommend using that one as well to avoid any other similar pacakges import { fileFromSync } from 'fetch-blob/from.js'
import { FormData } from 'formdata-polyfill/esm.min.js'
const fd = new FormData()
const file = fileFromSync('./package.json')
fd.append('upload', file)
fetch(url, {method: 'post', body: fd}) There are a way to get it without installing it if you do: const FormData = (await new Response(new URLSearchParams).formData()).constructor this way you will always depend on same version as we use. |
Purpose
res.buffer
is no good as it's a nodejs only feature, if ppl depend on this it only makes it more node-specificwe now strive to more spec compatible ways and more cross platform solutions.
Changes
This will output a one time warning when using form-data
