84669 人學習
152542 人學習
20005 人學習
5487 人學習
7821 人學習
359900 人學習
3350 人學習
180660 人學習
48569 人學習
18603 人學習
40936 人學習
1549 人學習
1183 人學習
32909 人學習
express中判斷使用者登入(使用了sequelize和co)但是是return res之後才看到console.log中的資訊。如何使得執行完co中的函數才return?
一般是返回個Promise,使用的地方也要then一下。
UserBLL.GetByName = function(name) { return co(function() { return yield User.findOne({where: {username: name}}) }) } UserBLL.GetByName('xxx').then(function(res) { console.log(res) })
雷雷
一般是返回個Promise,使用的地方也要then一下。
雷雷