I am working with Nodejs,I am using expressjs, I am new in express, Right now i am creating an "API",But i am getting following error await is only valid in async function Here is my current code,How can i fix this issue
const UploadImage = async (req, res) => {
uploadUserImage(req,res,function(err) {
const file = req.file;
const UserId=req.body.UserId;
console.log(file); // Getting file information
if (!file) {
return res.status(400).send({ message: 'Please upload a file.' });
}
if(!salonId)
{
return res.status(400).send({ message: 'Please enter shopId' });
}
const result= await User.addVendorGalleryImages(req.file.filename,salonId);
res.end("File is uploaded"+req.file.filename);
});
}