Saturday 22 April 2017

Error: Can't set headers after they are sent

In my node app, I have routes called index and home. While trying to redirect from index to home route it throws the following error:

Error: Can't set headers after they are sent

Here is the code:

app.get('/index', function (req, res) {
  res.redirect('/home');
})
app.get('/home', function (req, res) {
  res.send('Welcome Home !!');
})



via iJade

No comments:

Post a Comment