Fix Express body-parser req.body with formdata is empty object

October 08, 2020

formdata is empty object nodejs

To handle it via express use multer. Here is an example -

Make sure to addenctype="multipart/form-data"on form element. Otherwise Multer will ignore it.

let multer = require('multer');
let upload = multer();'/save', upload.fields([]), (req, res) => {
  console.log( req.body );
  console.log( req.files );

Written by Manoj Bhardwaj who lives and works in Dharamshala Himachal Pradesh (India). My stackoverflow