Replies: 1 comment 2 replies
-
you don't need to import secondly, you should not be creating a stream from a buffer and then convert it to a blob, just create a blob directly with the buffer insteand of using BlobFromStream and for the third: you should not specify the content-type yourself when posting a formdata as that is being done for you automatically. it is neccessary to omit this cuz we also need to add the boundary key/value meta in the content-type header so all in all: import fetch, { FormData, File } from 'node-fetch'
const formData = new FormData()
const file = new File([buffer], filename)
formData.append('file', file)
const response = await fetch(URL, {
method: 'POST',
body: formData
})
const result = await response.arrayBuffer() |
Beta Was this translation helpful? Give feedback.
-
When you call fetch like this:
it does not log a warning, it does not throw any error, yet it does not send ANY body. The request is sent with empty body.
Why?
Also I ran into a claim that when you do this in a browser, that the browser just ignores the header and sends the body as expected.
If that is the case, maybe node-fetch should override the header in this case too to align with how browsers deal with this weird situation?
If maintainers agree, I would love to open an issue for this and maybe even a PR.
Beta Was this translation helpful? Give feedback.
All reactions