Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当腾讯服务器返回空时,做判断 #12

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ exports.wrapper = function (callback) {
err.name = 'WeChatAPI' + err.name;
return callback(err, data, res);
}
if (data.errcode) {
if (data==null ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有相应数据是不是腾讯有什么逻辑是这样的?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

并没有说有空返回的情况。我猜是腾讯这边的问题,之前也偶尔会返回另一个错误

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (data && data.errorcode) { 这样改就行了。

err = new Error('no response data');
err.name = 'WeChatAPIError';
err.code = '-1';
return callback(err, data, res);
}
else if (data.errcode) {
err = new Error(data.errmsg);
err.name = 'WeChatAPIError';
err.code = data.errcode;
return callback(err, data, res);
}

callback(null, data, res);
};
};