var express = require('express');
var app = express.createServer();
app.listen(8000);
var tweets = [];
app.get('/', function(req,res){
res.send('Welcome to Node Twitter');
});
app.post('/send', express.bodyParser(), function(req,res){
if(req.body && req.body.tweet) {
tweets.push (req.body.tweet)
}
})
This simple code not working. Showing Segmentation Fault.. express version: 2.3.10 node.js version: 0.4.2
.I cant work in other versions . have to work in these only.
You should use:
app.use(express.bodyParser());
then do your post like this:
app.post('/send', function(req,res){
if(req.body && req.body.tweet) {
tweets.push (req.body.tweet)
}
});