Cant find variable:at request fail call
1. result is not defined;at App post function;at api request fail callback function
- Can’t find variable: result;at pages/home/home requestHomeData function;at api request fail callback function
后台发现好多这种错误,都是 result is not defined at api request fail callback function,但是相应的 method 里面并没有任何 result,而且我确定所有的 result 都做了空判断,官方能指点指点吗?
pages/home/home requestHomeData function:
requestHomeData: function () { let that = this ; wx.login({ success: function (res) { res.code && app.post(Url.home, {city: that.data.currentCityName, code: res.code}).then(res => { res.data && that.handleHomeData(res.data); }); } }); }, |
App post function:
/** * 封装 post 请求为 Promise * [@param](/user/param) url * [@param](/user/param) data * [@param](/user/param) header * [@returns](/user/returns) {*|Promise<any>} */ post: function (url, data, header = {}) { if ( this .globalData.deviceSerialNumber) { header = {...header, 'device-serial-number' : this .globalData.deviceSerialNumber}; } return url && data && new Promise((resolve, reject) => { wx.request({ url: url, method: 'POST' , data: data, header: { 'content-type' : 'application/json' , // 微信默认就是 ...header }, success: function (res) { resolve(res); }, fail: function (res) { reject(res); } }) }); }, |