i've got small app storing list of episodes. i've got table serie, seasons , table episode. table seasons got field "serie" of type objectid of serie. i've got select list list of serie items, when pick 1 item dropdown method getseasons triggered i'm getting 400 bad request error.
my files:
- series.server.routes.js
app.route('/serie/:serieid/seasons') .get(seasons.seasonslist); - seasons.server.controller.js
exports.seasonslist = function(req, res, id) { season.find({'serie': id}).exec(function(err, series) { if (err) { return res.status(400).send({ message: errorhandler.geterrormessage(err) }); } else { res.jsonp(series); } }); }; - episodes.client.controller.js
var seasons = $resource('/serie/:serieid/seasons', {serieid: '@id'}); seasons.get({'serieid': $scope.serie}, function (data) { console.dir(data); }); but despite i've route set i'm getting 400 bad request... why that?
i want achive same thing when type in mongo:
db.seasons.find({'serie': new objectid('serieid')})
the problem parameters. solution problem change seasonslist method parameter reqest this:
exports.seasonslist = function(req, res) { season.find({'serie': req.params.serieid}).exec(function(err, series) { if (err) { return res.status(400).send({ message: errorhandler.geterrormessage(err) }); } else { res.jsonp(series); } }); };
Comments
Post a Comment