I've configured my nodejs/express application as follows;
app.set('views', __dirname + './views');
app.set('view engine', 'ejs');
Then I added a route like so
app.get('/page/MyPage', function(req, res) {
// res.statusCode = 200; // Setting the status code here has no effect on the error.
res.render('MyPage', { Data: "Stuff" });
});
However, whenever I request the page http://localhost:8000/page/MyPage
node crashes out with TypeError: Cannot call method 'toString' of undefined
, breaking in the http.js
class.
The exact line:
var statusLine = 'HTTP/1.1 ' + statusCode.toString() + ' ' +
reasonPhrase + CRLF; // Aprox line 1180, in ServerResponse.prototype.writeHead = function(statusCode) function.
I've tried adding extensions to the 'MyPage' within render, and also tried other view engines. All of which yield the same result.
The view does exist in the /views directory.
Does anybody have any suggestions?