I have developed a small app to store a list of episodes. There are tables for Series, Seasons, and Episodes. The Seasons table has a field "serie" which is an ObjectId reference to the Serie table. I have a dropdown select list with Serie items, and when I choose one item from the list, the getSeasons method is triggered. However, I am encountering a 400 Bad Request error.
Here are 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);
});
Despite having set up the route, I am still receiving a 400 bad request error. Any idea why this might be happening?
I am aiming to achieve the same functionality as typing this command in mongo:
db.seasons.find({'serie': new ObjectId('SerieId')})