My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

node async await with sequlize not working properly?

Atul kumar's photo
Atul kumar
·May 8, 2019

have made an api to upload my in image into cloudinary and also save the image path in the database.but i'm getting the following error:- Sequelize database error (as null error is sent in the place of image) and here is the following code i'm using:-

router.post('/upload',upload.single('image'),async(req,res)=>{ const image = await cloudinary.v2.uploader.upload(req.file.path).secure_url;

Image.create({ image }).then(result=>{ res.status(200).json({ message:'Image saved' }); }).catch(err=>{ res.status(403).json({ message:'error occured', error:err }); }); });

how can improve in the sequelize section in order to save the data in the database ?