我知道像async.js这样的库,但现在我正在构建一些小的东西(ardiunio)所以我尽量不要复杂化。
我对下面的代码感到困惑。此
..
router.post('/do_something', function(req, res) {
Account.updateStatus(req.body.username, function(err,result){
//res.json(result); comment it out to avoid error
});
Photo.getApprovedPhotos(req.body.username,function(err,result){
res.json(result);
});
});
帐户和照片是带查询的模型,两者都返回其回调。我的困惑是如何构建代码。如果我将一个嵌套在另一个之内,那就不再是异步。