My code looks like this :
router.put('/stories/:story', function(req,res,next){
Story.findById(req.story._id, function(err, story) {
if (err) {
res.send(err);
}
story.scenarios.push(req.body);
story.save(function(err,story) {
if (err) {
res.send(err);
}
res.json(story);
})
});
});
The req.body contains an object with an image and an audio. I want to be able to update this array with new objects. How do I push new objects to story.scenario (who is null in the beginning).
Now I get an error : 'cannot read property push of null'
Somebody who knows the solution?