报错了 Unhandled rejection TypeError
来源:
满天飞2
2016-11-01
报错了:
Unhandled rejection TypeError: Cannot read property 'expires_in' of undefined
at /Users/apple/project_2016/node-wechat/wechat/g.js:69:9
Wechat.prototype.updateAccessToken = function() {
var appID = this.appID
var appSecret = this.appSecret
var url = api.accessToken + '&appid=' + appID + '&secret=' + appSecret
return new Promise(function(resolve,reject){
request({url: url, json: true}).then(function(response){
var data = response[1]
var now = new Date().getTime()
var expires_in = now + (data.expires_in - 30 ) * 1000
data.expires_in = expires_in
resolve(data)
})
})
}
写回答
2回答
-
Scott
2016-11-02
通过 response.body 替代 response[1] 试试
00 -
楼燕
2016-11-02
var data = response[1] 换成 response.body00
相似问题