[Vuejs]-How to get image url location from Aws s3 and store it in mongodb

0👍

Seem like you misplaced uploadFile line.
You need to upload the file first, then get the url and put it to Rope payload

router.post('/', upload.single('image'), async (req, res) => {

const fileUploaded = await uploadFile(req.file)
const { Location } = fileUpload
const rope = new Rope({
    title: req.body.title,
    description: req.body.description,
    image: Location,
    price: req.body.price,
    cartQuantity: req.body.cartQuantity,

});
  try {
    await rope.save();
    res.status(201).json(rope);
    console.log(req.body)
  } catch (err) {
    res.status(400).send(err);
  }
});

Leave a comment