lrf402788946 4 years ago
parent
commit
80b9f6dbe5
1 changed files with 2 additions and 2 deletions
  1. 2 2
      app/service/weixin.js

+ 2 - 2
app/service/weixin.js

@@ -72,12 +72,12 @@ class WeixinAuthService extends AxiosService {
     if (!jsapi_ticket) {
       // 1,重新获取access_token
       const atUrl = `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appid}&secret=${appSecret}`;
-      const req = await this.ctx.curl(atUrl, { method: 'GET' });
+      const req = await this.ctx.curl(atUrl, { method: 'GET', dataType: 'json' });
       if (req.status !== 200) throw new BusinessError(ErrorCode.SERVICE_FAULT, 'access_token获取失败');
       const access_token = _.get(req, 'data.access_token');
       // 2,获取jsapi_token
       const jtUrl = `https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=${access_token}&type=jsapi`;
-      const jtReq = await this.ctx.curl(jtUrl, { method: 'GET' });
+      const jtReq = await this.ctx.curl(jtUrl, { method: 'GET', dataType: 'json' });
       if (jtReq.status !== 200) throw new BusinessError(ErrorCode.SERVICE_FAULT, 'jsapi_ticket获取失败');
       console.log(jtReq);
       jsapi_ticket = _.get(jtReq, 'data.ticket');