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文档