How do I send a form with a request promise?
I am trying to use the request-promise library or anything similar to send files via a post request from node to another machine that is running Node. Using the normal request module I could so something like
var req = request.post(url, function (err, resp, body) {
if (err) {
console.log('Error!');
} else {
console.log('URL: ' + body);
}
});
var form = req.form();
form.append('file', '<FILE_DATA>', {
filename: 'myfile.txt',
contentType: 'text/plain'
});
This code is from the question:
Uploading file using POST request in Node.js however it is not using promises.
Can anyone explain how to do the same thing but with the request-promise library or if there is any other way to promisify this?