I have a client side form using XMLHTTPResponse that allows me to get response data saved as a file. It sets the response type as arraybuffer as follows before the rest of the blob conversion occurs:
xhr.responseType = "arraybuffer";
I have been searching and finding multiple methods to create an arraybuffer, but none that detail how to take the response in node to an arraybuffer. I am using unirest as follows:
unirest.post('http://myvendorsapi/Upload_PDF')
.headers({ 'Content-Type': 'multipart/form-data' })
.field('filename', filename)// Form field
.attach('file', fileloc)// Attachment
.end(function (response) {
console.log(response);
var returnfile = response.body;
// Need logic to convert to arraybuffer
});
How do I set the response type to an arraybuffer or convert my response to an arraybuffer?