请求微信接口 报40001 token过过期 重新刷新token

This commit is contained in:
Wang Kejun 2023-02-07 20:43:18 +08:00
parent 7e6c42cee8
commit 0bfac346bc
6 changed files with 18 additions and 0 deletions

View File

@ -47,6 +47,9 @@ var WechatMpInstance = /** @class */ (function () {
case 2:
json = _a.sent();
if (typeof json.errcode === 'number' && json.errcode !== 0) {
if (json.errcode === 40001) {
this.refreshAccessToken();
}
throw new Error("\u8C03\u7528\u5FAE\u4FE1\u63A5\u53E3\u8FD4\u56DE\u51FA\u9519\uFF0Ccode\u662F".concat(json.errcode, "\uFF0C\u4FE1\u606F\u662F").concat(json.errmsg));
}
return [2 /*return*/, json];

View File

@ -51,6 +51,9 @@ var WechatPublicInstance = /** @class */ (function () {
case 2:
json = _a.sent();
if (typeof json.errcode === 'number' && json.errcode !== 0) {
if (json.errcode === 40001) {
this.refreshAccessToken();
}
throw new Error("\u8C03\u7528\u5FAE\u4FE1\u63A5\u53E3\u8FD4\u56DE\u51FA\u9519\uFF0Ccode\u662F".concat(json.errcode, "\uFF0C\u4FE1\u606F\u662F").concat(json.errmsg));
}
return [2 /*return*/, json];

View File

@ -51,6 +51,9 @@ var WechatWebInstance = /** @class */ (function () {
case 2:
json = _a.sent();
if (typeof json.errcode === 'number' && json.errcode !== 0) {
if (json.errcode === 40001) {
this.refreshAccessToken();
}
throw new Error("\u8C03\u7528\u5FAE\u4FE1\u63A5\u53E3\u8FD4\u56DE\u51FA\u9519\uFF0Ccode\u662F".concat(json.errcode, "\uFF0C\u4FE1\u606F\u662F").concat(json.errmsg));
}
return [2 /*return*/, json];

View File

@ -38,6 +38,9 @@ export class WechatMpInstance {
if (contentType.includes('application/json')) {
const json = await response.json();
if (typeof json.errcode === 'number' && json.errcode !== 0) {
if (json.errcode === 40001) {
this.refreshAccessToken();
}
throw new Error(
`调用微信接口返回出错code是${json.errcode},信息是${json.errmsg}`
);

View File

@ -58,6 +58,9 @@ export class WechatPublicInstance {
if (contentType.includes('application/json')) {
const json = await response.json();
if (typeof json.errcode === 'number' && json.errcode !== 0) {
if (json.errcode === 40001) {
this.refreshAccessToken();
}
throw new Error(
`调用微信接口返回出错code是${json.errcode},信息是${json.errmsg}`
);

View File

@ -41,6 +41,9 @@ export class WechatWebInstance {
if (contentType.includes('application/json')) {
const json = await response.json();
if (typeof json.errcode === 'number' && json.errcode !== 0) {
if (json.errcode === 40001) {
this.refreshAccessToken();
}
throw new Error(
`调用微信接口返回出错code是${json.errcode},信息是${json.errmsg}`
);