routes1>
todos1.js
const route1 = require(‘express’).Router()
let todos1=[
{task: “This is the first task”},
{task: “This is another task”}
]
route1.get(’/’,(req,res)=>{
res.render(‘todos1’,{todos1})
})
route1.post(’/’,(req,res)=>{
})
module.exports = route1
todos1.hbs
Document<body>
<form action="/todos1" method="POST">
<input name="newtodo1">
<input type="submit">
</form>
<ul>
{{#each todos1 as |todo1|}}
<li>{{todo1.task}}</li>
{{/each}}}}
</ul>
</body>
*********************
serverX.js
const express = require('express')
const todoRoute1 = require(’./routes1/todos1’)
const srv1=express()
srv1.set(‘view engine’, ‘hbs’)
srv1.set(‘views’,__dirname+"/views1")
srv1.use(express.json())
srv1.use(express.urlencoded({extended:true}))
srv1(’/todos1’,todoRoute1)
srv1.listen(3456)
error :-
/Users/deeptisharma/Desktop/Ajax1/express_serverside_rendering/node_modules/express/lib/router/index.js:160
req.next = next;
^
TypeError: Cannot create property ‘next’ on string ‘/todos1’
at Function.handle (/Users/deeptisharma/Desktop/Ajax1/express_serverside_rendering/node_modules/express/lib/router/index.js:160:12)
at Function.handle (/Users/deeptisharma/Desktop/Ajax1/express_serverside_rendering/node_modules/express/lib/application.js:174:10)
at app (/Users/deeptisharma/Desktop/Ajax1/express_serverside_rendering/node_modules/express/lib/express.js:39:9)
at Object. (/Users/deeptisharma/Desktop/Ajax1/express_serverside_rendering/serverX.js:21:1)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47