This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.createProduct = async (req, res, next) => { | |
try { | |
if (!req.file) { | |
const error = new Error("No image provided."); | |
error.statusCode = 422; | |
return next(error); | |
} | |
const image = req.file.path.replace("\\", "/").replace("\\", "/"); | |
const { title, price, category, desc } = req.body; | |
const product = new Product({ |