I tried a lot to find out why this error causes an error:
Configuring Listening on 2000 TypeError: Cannot read property 'title' of undefined at /home/abdulsattar/learning/node/express/index.js:9:20
.Js index:
var express = require("express"), app = express.createServer(); app.get("/", function(req, res) { res.send('<form action="/new" method="post"><input type="text" name="title" /><input type="submit" /></form>'); }); app.post("/new", function(req, res) { res.send(req.body.title); }); app.configure(function() { console.log("Configuring"); app.use(express.bodyParser()); }); var port = process.env.PORT || 2000; app.listen(port, function() { console.log("Listening on " + port); });
I read that express needs bodyParser() . i use d it is higher, but it always fails. I tried it in versions 2.5.8 and 2.5.8 (thinking that this might be a problem), but it failed for both versions. Is something missing?
source share