Lado del servidor:
app.get("/basket", (req, res) => { fs.readFile("products.json", (err, data) => { if (err) { res.status(500).end() } else { res.render("basket", {products: JSON.parse(data)}) } }) })JSON:
{ "product_one": [ { "name": "Laptop", "price": 799 } ], "product_two": [ { "name": "Laptop", "price": 799 } ] }Interfaz:
<small>Price: £{{products.product_one.price}} </small>He intentado mostrar el precio en el front-end usando hbs pero no aparece nada
Recorrer la lista solucionó el problema:
{{#products}} <small>Price: £ {{price}}</small> {{/products}}