为了账号安全,请及时绑定邮箱和手机立即绑定

获取微信token时终端中报错ReferenceError: fasle is not defined

获取微信token时终端中报错ReferenceError: fasle is not defined

慕仙3125880 2018-04-15 11:13:45
import request from 'request-promise'const base = 'https://api.weixin.qq.com/cgi-bin/'const api = { accessToken: base + 'token?grant_type=client_credential'}export default class Wechat { constructor(opts){ this.opts = Object.assign({}, opts) this.appID = opts.appID this.getAccessToken = opts.getAccessToken this.saveAccessToken = opts.saveAccessToken this.fetchAccessToken() } async request (options){ options = Object.assign({}, options, {json:true}) try { const response = await request(options)     console.log(response)     return response } catch (error) { console.error(error) } } async fetchAccessToken () { let data = await this.getAccessToken() if(!this.isValidAccessToken(data)){ data = await this.updateAccessToken() } await this.saveAccessToken(data) return data } async updateAccessToken () {     const url = api.accessToken + '&appid=' + this.appID + '&secret=' + this.appSecret       const data = await this.request({url: url})       const now = (new Date().getTime())       const expiresIn = now + (data.expires_in - 20) * 1000       data.expires_in = expiresIn       return data    }     isValidAccessToken (data) { if (!data || !data.access_token || !data.expires_in) { return fasle } const expiresIn = data.expires_in const now = (new Data().getTime()) if (now < expiresIn) { return true } else { return fasle }  }}   
查看完整描述

1 回答

已采纳
?
QQ_随意

TA贡献51条经验 获得超28个赞

if (now < expiresIn) {

return true

} else {

return fasle

}

return false


false 拼错了

查看完整回答
反对 回复 2018-04-16
  • 1 回答
  • 0 关注
  • 1746 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信