From b7ce4f7ce4409d37d783130136d072c9dbf0520b Mon Sep 17 00:00:00 2001 From: jchbh-duplicate Date: Sat, 12 Mar 2016 23:24:10 -0400 Subject: [PATCH 1/2] Update api_common.js --- lib/api_common.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/api_common.js b/lib/api_common.js index b176a3d..a5cb343 100644 --- a/lib/api_common.js +++ b/lib/api_common.js @@ -161,7 +161,7 @@ API.prototype.preRequest = function (method, args, retryed) { var that = this; var callback = args[args.length - 1]; // 调用用户传入的获取token的异步方法,获得token之后使用(并缓存它)。 - that.getToken(function (err, token) { + that.getToken(function TokenReady(err, token) { if (err) { return callback(err); } @@ -173,7 +173,8 @@ API.prototype.preRequest = function (method, args, retryed) { var retryHandle = function (err, data, res) { // 42001 重试 if (data && data.errcode && data.errcode === 42001) { - return that.preRequest(method, args, true); + retryed = true; + return TokenReady(null, null); } callback(err, data, res); }; From a1abaae4802fdbec1fcdd05ccfeab1539812fb54 Mon Sep 17 00:00:00 2001 From: jchbh Date: Sat, 12 Mar 2016 23:58:17 -0400 Subject: [PATCH 2/2] fix token incorrect with reload action --- lib/api_common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api_common.js b/lib/api_common.js index a5cb343..d17ec43 100644 --- a/lib/api_common.js +++ b/lib/api_common.js @@ -172,7 +172,7 @@ API.prototype.preRequest = function (method, args, retryed) { if (!retryed) { var retryHandle = function (err, data, res) { // 42001 重试 - if (data && data.errcode && data.errcode === 42001) { + if (data && data.errcode && (data.errcode === 42001 || data.errcode === 40014)) { retryed = true; return TokenReady(null, null); }