From 42b9331a2be5cf2179478154da242d524814ebff Mon Sep 17 00:00:00 2001 From: starkwang <381152119@qq.com> Date: Mon, 14 Mar 2016 14:51:40 +0800 Subject: [PATCH] promisefy --- index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 1c99f4c..e61ea08 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ var Promise = require('bluebird'); var getAllFollowees = { counter: 0, - store:[], + store: [], request: function(options) { if (!options) { var options = {}; @@ -31,22 +31,22 @@ var getAllFollowees = { console.log(_this.counter + ' complete'); if (tmp.length > 0) { _this.counter = _this.counter + 20; - _this.request(options); + resolve(_this.request(options)); } else { - _this.complete(); + resolve({ + data: _this.store + }); }; }) }) - }, - complete:function(){ - console.log("========RESULT========"); - console.log(this.store); - console.log("========RESULT========"); } } getAllFollowees.request({ followees: true +}).then(function(result) { + console.log("success!!!"); + console.log(result); }) function parseCard(text) {