I have a frontend app(react) where the user can edit the product like price, description, delete images and add images. The problem occurs when the user does not want to add new images.
Then on the backend(nodejs) req.files.newImages as I named it is null and the backend crashes.
When I add one image or more everything works as it should because req.files.newImages has a value.
How to cover the case when the user does not want to add new images and prevent the app from crashing
I use express-fileupload and I use axios and put method to send data.
routes.put("/edit-product", (req, res) => {
console.log(req.files.newImages) // - result app crashed
}
Error in console: TypeError: Cannot read property 'newImages' of null;