小游戏request后没有response
发布于 6 年前 作者 jiexue 18559 次浏览 来自 问答

已经设置好了合法域名(https的)

wx.request POST 时,request可以出去,在服务端也接收到了POST数据,但是客户端接收不到response,没有报错信息,有遇到类似问题的吗?

另,如果不校验域名,则可以正常进行网络请求。

以下为代码段

static getToken(param = { 

    url: String, 

    tempCode: String, 

    response: Function, 

    complete: Function

  }) {

    let isSuccess = false

    wx.request({

      url: param.url,

      data: {

        noncestr: Date.now(),

        code: param.tempCode

      },

      method: ‘POST’,

      success: (result) => {

        isSuccess = true

        if (typeof param.response === “function”) param.response(result.data)

      },

      complete: () => {

         if (typeof param.complete === ‘function’) param.complete(isSuccess)

         }

    })

  }

2 回复

我也遇到了这个问题,同样是在校验域名的情况下,真机体验是正常的,只有开发工具没有走到回调

在wx.request的complete输出下返回内容看看咯

回到顶部