WebDevSimplified/Node.js-Stripe-Shopping-Cart

Render ejs not working

Jazour11 opened this issue · 2 comments

Hello,

I have having a similar issue to Khushbu11-web. Everything is fully functional until I switch the store.html file to ejs. Once I do this it says cannot GET /store.html in localhost 3000. I did check, and I am using app.set('view engine','ejs'). Any help would be greatly appreciated.

Hello,

I have having a similar issue to Khushbu11-web. Everything is fully functional until I switch the store.html file to ejs. Once I do this it says cannot GET /store.html in localhost 3000. I did check, and I am using app.set('view engine','ejs'). Any help would be greatly appreciated.

try http://localhost:3000/store

You are needed to write this code into server.js. Sorry for my previously message. You are nedded only add this code in server.js:
app.get('/store', function(req, res) { fs.readFile('items.json', function(error, data) { if (error) { res.status(500).end() } else { res.render('store.ejs', { stripePublicKey: stripePublicKey, items: JSON.parse(data) }) } }) })