I have a Node.JS project with a server-side and a client-side powered by webpack. I was hoping to convert my project from a combination of axios/request to just use request, but I'm having issues doing file uploads from the browser. I'm using the request-promise library, but I have the same issue whether I'm using request or request-promise. My attempt is to do this:
return request.post({
uri: `${BASE_URL}/files`,
formData: {
token: token,
file: {value: filedata, options: {filename: filename}}
}
})
where filedata is a File object returned from using an input tag to find a file on the user's computer. The error I get is:
TypeError: self._form.on is not a function
This seems to be because formData requires a readable stream from something like fs. How do I get the correct input to request?