I am wondering if in the following scenario am I am handling the right way the error and what is that I should return on error? Can you return statusCode on anything or only on response?
const storage = multer.diskStorage({
destination: function (req, file, cb) {
if (err) {
new Error({
status: "INTERNAL SERVER ERROR"
})
}
let filepath = './public/images/'
cb(null, filepath)
},
filename: function (req, file, cb) {
if (err) {
new Error({
status: "INTERNAL SERVER ERROR"
})
}
let ext = file.originalname.split(".").pop();
let filename = file.fieldname + '-' + Date.now() + '.' + ext
//console.log(ext);
cb(null, filename);
}
})