You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using got 12.0.1, I get the error "RequestError: The body option must be a stream.Readable, string or Buffer" on the following code
var fd = require('formdata-node').FormData;
var form = new fd();
form.set('t', text);
var body = await got.post('<my url>', {
"body": form,
headers: {
"Content-Type": 'multipart/form-data',
"Authorization": "Basic ..."
}
}).json();
@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.
The text was updated successfully, but these errors were encountered: