Request.body is undefined


Adopting the tutorial to use request.body instead of request.query:"/dreams", function (request, response) {

```TypeError: Cannot read property 'dream' of undefined```

The log prints out "undefined". I'm sending in a body of ```{"dream":"Build something beautiful"}```


By default it will be undefined, you need to use body-parsing middleware such as body-parser. See the explanation on or view a working version at!/project/treasure-charger


Does this answer still hold? I seem to get an error trying to use body-parser

Error: Cannot find module ‘body-parser’

This happens any time I add

var bodyParser = require(‘body-parser’);


Have you included body-parser in the dependencies list in your package.json file?


I didn’t. Works now. Thanks for you help, I am a node newbie.


Cool, glad that helped. Let us know any other probs you run into. I’m still learning this stuff too.