curl with nodejs express – POST数据

我试图模拟一个POST请求到一个基于Express的服务器应用程序nodeJS。 它运行在localhost:3000 (JS小提琴: http : //jsfiddle.net/63SC7/ )

我使用下面的CURL行:

  curl -X POST -d "{\"name\": \"Jack\", \"text\": \"HULLO\"}" -H "Content-Type: application/json" http://localhost:3000/api 

但是收到错误信息:

 Cannot read property 'text' of undefined 

任何想法我做错了什么?

注意:我可以使用这一行进行成功的GET请求:

curl http://localhost:3000/api

假设你正在尝试req.body.text

use d bodyParser

 app.use(express.bodyParser());