收藏
回答

Cant find variable:at request fail call

问题模块 框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
API和组件 小程序 Bug wx.request 客户端 6.6.7 2.0.9


1. result is not defined;at App post function;at api request fail callback function

2. 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 url
   * @param data
   * @param header
   * @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);
        }
      })
    });
  },



最后一次编辑于  2018-06-08  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏投诉关注问题回答

10 个回答