Recently starting out with node development.
Encountering the error below:
TypeError: req.redirect is not a function
at Post.create (/var/www/html/node_blog/index.js:40:7)
at /var/www/html/node_blog/node_modules/mongoose/lib/utils.js:276:16
at Function.<anonymous> (/var/www/html/node_blog/node_modules/mongoose/lib/model.js:4798:21)(/var/www/html/node_blog/node_modules/mongoose/lib/model.js:486:7)
at /var/www/html/node_blog/node_modules/kareem/index.js:315:21
Emitted 'error' event at:
at /var/www/html/node_blog/node_modules/mongoose/lib/model.js:4781:13
at /var/www/html/node_blog/node_modules/mongoose/lib/utils.js:276:16
[... lines matching original stack trace ...]
at process._tickCallback (internal/process/next_tick.js:61:11)
Presented here is my code snippet:
app.post('/post/save', (req, res) => {
Post.create(req.body, (err, post) => {
req.redirect('/');
});
});