Is it possible to send additionally to the file and json object containing data with multer? I found this thread. But it only explains how to attach one field at the time.
Here what i have currently on client side:
request
.post(uploadPOSTUrl)
.set('Accept', 'application/json')
.field('Test', object.TestField)
.attach('file', file)
.end((err, res) => {
if (err) {
} else {
}
});
and server side
export function upload(req, res){
console.log("UploadedJSON: ", req.body);
console.log("UploadedFile: ",req.file);
res.status(204).end();
}
but instead of just sending 1 field. I need to send the whole object .field('Test', object)
. When i do this, i receive [Object object]
on the server side and can't access the fields.
My only solution right now would be to loop and add .field()
for every field in my object...