Tuesday 28 May 2019

little help i have a error says Photo is not defined

router.post("/images/add", async (req, res) => {const result = await cloudinary.v2.uploader.upload(req.file.path);const newPhoto = new Photo({imageUrl: result.url,public_id: result.public_id});await newPhoto.save().then(newPhoto => {res.status(200).json('added successfully')}).catch(err => {res.status(400).json.send('adding new photo failed')})await fs.unlink(req.file.path);})​backend code error......mongodb connection is working(node:14020) UnhandledPromiseRejectionWarning: ReferenceError: Photo is not definedat router.post (C:\Users\Dante Delgadillo\Desktop\upload images\backend\routes\index.js:21:22)at process._tickCallback (internal/process/next_tick.js:68:7)(node:14020) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). (rejection id: 1)(node:14020) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Submitted May 28, 2019 at 04:35PM by ddante93

No comments:

Post a Comment