I am creating pages dynamically with gatsby-node.js file
let allProducts = result.data.allProducts.edges
createPage({
path: `/products`,
component: require.resolve('./src/pages/products.js'),
context: { allProducts }
});
//Create a page for each Product.
allProducts.map((edge)=>{
let product = edge.node
createPage({
path:`/product/${product.id}`,
component: require.resolve('./src/pages/product.js'),
context:{product}
})
})
Gatsby develop is running fine but when i do gatsby build it gives error
error Building static HTML for pages failed
See our docs page on debugging HTML builds for help https://gatsby.app/debug-html
43 | <div >
44 | <Img fluid={data.bannerHeaderProduct.childImageSharp.fluid}/>
> 45 | <img src={product.imgSrc }alt=""/>
| ^
46 | </div>
47 | <div>
48 | <h3 dangerouslySetInnerHTML={{__html:product.name}}>
WebpackError: TypeError: Cannot read property 'imgSrc' of undefined
product which i am passing as context to pages is getting undefined