|
|
@ -17,16 +17,16 @@ module.exports.createProduct = async (req, res) => {
|
|
|
|
name,
|
|
|
|
name,
|
|
|
|
price,
|
|
|
|
price,
|
|
|
|
description,
|
|
|
|
description,
|
|
|
|
inventory,
|
|
|
|
inventory
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Save the product to the database
|
|
|
|
// Save the product to the database
|
|
|
|
await product.save();
|
|
|
|
await product.save();
|
|
|
|
|
|
|
|
|
|
|
|
res.status(201).json({ message: 'Product created successfully', product });
|
|
|
|
res.status(201).json(true);
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
console.error(error);
|
|
|
|
res.status(500).json({ message: 'Error creating product' });
|
|
|
|
res.status(500).json(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|