Thursday 10 December 2015

Express.js path issue

I'm trying to render html files but I'm having an issue.This works.app.get('/randomlink', function(req, res) { res.sendFile( __dirname + "/views/" + "test2.html" ); }); But I don't want to copy and paste dirname thingy over and over, so I tried this. app.use(express.static(path.join(__dirname, 'views'))); app.get('/randomlink', function(req, res) { res.sendFile('test2.html'); }); My express version is 4.13Here's the error.path must be absolute or specify root to res.sendFile

Submitted December 11, 2015 at 05:22AM by laraveling

No comments:

Post a Comment