give error to user if url to name failed

This commit is contained in:
Wingysam 2018-11-22 09:30:21 -05:00
parent 8659289bef
commit 51c2ee3ecc

View file

@ -46,7 +46,9 @@ module.exports = (db) => {
let productData; let productData;
try { try {
if (isUrl) productData = await getProductName(req.body.itemUrlOrName, config.proxyServer); if (isUrl) productData = await getProductName(req.body.itemUrlOrName, config.proxyServer);
} catch (err) {} } catch (err) {
req.flash('error', err.toString());
}
item.name = (productData ? productData.name : req.body.itemUrlOrName); item.name = (productData ? productData.name : req.body.itemUrlOrName);
item.addedBy = req.user._id; item.addedBy = req.user._id;
item.pledgedBy = (req.user._id === req.params.user ? undefined : req.user._id); item.pledgedBy = (req.user._id === req.params.user ? undefined : req.user._id);