liuyu 4 gadi atpakaļ
vecāks
revīzija
f9b1a3f380
1 mainītis faili ar 7 papildinājumiem un 1 dzēšanām
  1. 7 1
      app/controller/weixin.js

+ 7 - 1
app/controller/weixin.js

@@ -66,7 +66,13 @@ class WeixinController extends Controller {
     console.log('code-->' + code);
 
     const { weixin } = this.ctx.service;
-    const openid = await weixin.fetch(code);
+    let openid;
+    try {
+      ({ openid } = await weixin.fetch(code));
+    } catch (err) {
+      await this.ctx.render('error.njk', { title: err.message, message: err.details });
+      return;
+    }
     console.log('openid--->' + openid);
     if (openid) {
       const key = `visit:auth:state:${state}`;