Why are there 2 renders?
PS This is in the wrong category. It should be in HELP.
I set the view engine then why my test not pass
app.set(‘view-engine’, ‘pug’);
Hi.
I’m not sure where you’re at with the exercise. I hope you were able to successfully complete it and move forward.
For anyone having seemingly the same trouble, “view engine” isn’t hyphenated according to the documentation found at this link:
https://expressjs.com/en/guide/using-template-engines.html
1 Like
'use strict';
//const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const pug = require('pug');
const app = express();
fccTesting(app); //For FCC testing purposes
app.use('/public', express.static(process.cwd() + '/public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
//set up a template engine
app.set('view engine','pug');
app.route('/')
.get((req, res) => {
res.render(process.cwd() + '/views/pug/index', {title: 'Hello', message: 'Please login'});
});
app.listen(process.env.PORT || 3000, () => {
console.log("Listening on port " + process.env.PORT);
});
5 Likes
dont put screenshots on here dude. just paste the link to your project
2 Likes
after half an hour : ) got the problem, ‘view-engine’ —> ‘view engine’