In NodeJS I am trying to POST JSON data to the server along with a file using the following code:
unirest.post(url)
.headers(headers)
.send(data)
.attach('file', file)
.end(function (response) {
var statusCode = response.status;
if (statusCode != 200) {
console.log("Result: ", response.error);
}
});
However, on the server, I am only receiving the file, and not the JSON object from .send(data)
. I see there is a .multipart()
function I can use, but I'm not sure how best to use this?