I am trying to Upload file using multer, I would like to send error to React. My code is like below
const fileFilter = (req, file, cb) => { if (file.mimetype === 'image/jpeg' || file.mimetype === 'image/png') { cb(null, true); } else { cb(new Error('Try to upload .jpeg or .png file.'), false); } }; const upload = multer({ storage: storage, limits: { fileSize: 1024 * 1024 * 5 }, fileFilter: fileFilter }).single('addressImage'); upload(req, res, function(error) { if (error) { // An error occurred when uploading res.status(500).json({ error // I would like to send error from here, But I am not getting error in React. }); return; } }); -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/87f28226-ccf5-40c8-940c-e4413835af01%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.