I'm getting this error when trying to do a POST request using axios:
TypeError: data should be a string, Buffer or Uint8Array
Here is my code snippet:
var fs = require('fs'),
axios = require('axios');
var FormData = require('form-data');
var form = new FormData();
form.append('file', fs.createReadStream("qa_test_file_DOC.txlf"));
form.append('extractArchive', false);
let request_config = {
headers: {
'Authorization': `Bearer eyJhbGciOiJIUzI1NXXXX.....`,
...form.getHeaders()
}
}
let reqUrl = "https://XXXXX/XX/rest/v1/XXXXX";
try {
axios.post(reqUrl, form, request_config)
.then(function (response) {
console.log(response);
return callback(response);
})
.catch(function (error) {
console.log(error);
return callback(error);
});
} catch (ex) {
console.log("exception ", ex);
}
Tried using pipe, and most of possible solutions. file is exist. Not understanding what going wrong here. anything in Readstream ? Thanks for help.