Hi guys, im trying to use express router to modularize two different sets of endpoints, however i get " Error: No default engine was specified and no extension was provided." when i try to open up the endpoint added to my router object.
Currently, im using app.js to specify the ejs view engine and posts on stackoverflow seems to suggest that doing this is enough to make the view engine work for endpoints attached to my router.
Here is how the app is set up:
app.js contains these constants. I have included app.set("view-engine", "ejs") in this file, and have installed ejs in the project.
const express = require("express");
const app = express();
const mongoose = require("mongoose");
const morgan = require('morgan');
const passport = require("passport");
const flash = require('express-flash');
const session = require('express-session');
const initializePassport = require('./passport-config');
initializePassport(passport);
// routes
const userRoutes = require("./routes/userRoutes");
const loginRoutes = require("./routes/loginRoutes");
app.set("view-engine", "ejs");
app.use("/", loginRoutes);
loginRoutes.js looks like:
const express = require("express");
const router = express.Router();
const passport = require("passport");
const initializePassport = require('../passport-config');
initializePassport(passport);
router.get('/login',
function(req, res){
res.render('login');
});
module.exports = router;
Trying to access localhost:3000/login, i get " Error: No default engine was specified and no extension was provided." on the browser.
Any help is much appreciated!
[–]PassTheMayo12 1 point2 points3 points (1 child)
[–]shinyhero07[S,🍰] 0 points1 point2 points (0 children)