I am trying to send a file via the request npm library, but I keep getting the write after end
error. What's wrong? How can I fix this?
This is the way I'm doing this:
return new Promise((resolve, reject) => {
const callback = (error, response, body) => {
if (!error && response.statusCode < 400) {
resolve(body);
}
else {
reject(error); // Write after end
}
};
request({
url: "https://api.url.com/v2/",
method: "POST",
formData: fs.createReadStream("file"),
}, callback);
});
via user99999
No comments:
Post a Comment