I am currently developing a node.js application. My goal is to have the homepage rendered after the admin successfully uploads data, transitioning from localhost:3000/admin
to localhost:3000
. I attempted to achieve this using the code snippet below:
router.post('/', (req, res)=>{upload(req, res, function(err) {
if (err) {
console.log(err);
res.render('admin', {msg: err});
}else{
return res.redirect('index');
}
}
The accompanying index.js script looks like this:
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
module.exports = router;
However, despite having the title defined in index.js and seemingly correct express routing, an error occurred:
ReferenceError: E:\Documents\Computer and Coding\PlayGround\PROJECTS\Catalogue\views\index.ejs:4
2| <html>
3| <head>
>> 4| <title><%= title %></title>
5| <link rel='stylesheet' href='/stylesheets/style.css' />
6| </head>
7| <body>
title is not defined