Can not access Property error if pass incorrect format of image source url to load Node Express JS

Viewed 23
export function getProduct(req, res, next) {
    const productID = Number(req.params.productID);
    const fileRead = Product.fetchAll();
    fileRead.then((products) => {
        const productDetail = products.find((product) => productID === product.id);
        res.render('shop/product-detail.ejs', {product: productDetail, pageTitle: productDetail.title, path: '/products'});
    });
}

This is my code: I insert a dummy image source (well not dummy but just wrong format like spaces in between image source url), which is fed to the page through the product object that I am passing in render(). The problem that I get is that the page loads and it does access the pageTitle: productDetail.title that I am passing, but still in console it gives me following error: can not access undefined propert pageTitle: productDetail.title

But it reads this property, because my page title changes to its value (with correct image source url format even if the image does not load it does not give any error)

0 Answers
Related