I am trying to retrieve image file and json file together from a route and save all those information in MongoDB.
const petCheckoutDetails = new PetCheckoutDetails({
id: Date.now(),
name: req.body.name,
age: req.body.age,
image: imagefile,
petType: req.query.petType,
user: userid,
})
I can get the json from req.body and store it in database but for image I cannot just save it with multer simultaneously. So I tried creating a route for image /upload. Now I can save image and json separately. I want to save in the given upper format. Is there a way I can do it or just save the image there and somehow point that this image belongs to specific user. Any help will be appreciated.