Open octoberspice opened 2 years ago
@octoberspice I know it's an old issue, but if someone is reading this and struggle with this as well. Seems like adding form: true
to the options object solve this.
import { FormData } from "formdata-node";
import got from "got";
const form = new FormData();
form.set("text", "SOME_TEXT");
const data = await got.post("MY_URL", {
body: form,
form: true,
headers: {
"Content-Type": "multipart/form-data",
Authorization: "Basic ...",
},
});
I did not found mention of this requirement in the documentation...In addition, seems like using .json()
does not work with that combination.
@octoberspice @Nivg This issue seem to be related to another package, and not to this one. Please refer to the documentation of that package instead. Try latest version of got and formdata-node and if you have any issue - open a new one in my repo.
Using got 12.0.1, I get the error "RequestError: The
body
option must be a stream.Readable, string or Buffer" on the following codeDocumentation suggestions that this should work https://github.com/sindresorhus/got/blob/HEAD/documentation/2-options.md , Not sure what I am missing.