さまざまなユーザーがさまざまな記事を投稿できるようにする RESTful Web サービスが与えられた
サーバー側で関数を定義するには、サーバー側に 、 などの関数のようなGET
非同期関数が必要だと思いますlist
getTopViewed
getTopFavorite
次は正しいですか?
exports.get = function(req, res) {
db.articles.list(function etc)
db.articles.getTopViewed(function etc)
db.articles.getTopFavorite(function etc)
}
注:とはlist
、別の JavaScript ファイルで定義されています。getTopViewed
getTopFavorite
別の JS ファイルでは:
exports.list = function(callback){
// acts as async callback
var result = ArticleModel.find({}, function(err, articles){
callback(null, articles)
});
return result;
}