1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | function Wechat(opts){ let _this = this ; this .appID = opts.appID; this .appSecret = opts.appSecret; this .getAccessToken = opts.getAccessToken; this .saveAccessToken = opts.saveAccessToken; this .getAccessToken() .then( function (data){ try { data = JSON.parse(data); } catch (e){ return _this.updateAccessToken() } if (_this.isValidAccessToken(data)){ Promise.resolve(data); } else { return _this.updateAccessToken() } }) .then( function (data){ _this.access_token = data.access_token; // 这里报错了??第二次启动服务的时候 _this.expires_in = data.expires_in; _this.saveAccessToken(data); }) } |
Unhandled rejection TypeError: Cannot read property 'access_token' of undefined
at E:\360yun\study\koa\koa\g.js:33:29
第一次启动会写入wechat.txt文档