WeChat Mini Programs real machine test, must be in the mobile phone Wechat "turn on debugging" in order to send wx.request request?

The

code is simple, as follows:

wx.request({
  url: "https://......",
  method: "GET",
  header: {
    "content-type": "application/x-www-form-urlencoded"
  },
  success: function (res) {
    wx.showToast({
      title: "success"
    });
  },
  fail: function (res) {
    wx.showToast({
      title: "fail"
    });
  },
  complete: function (res) {
    wx.showToast({
      title: "complete"
    });
  }
})

this code has no problem debugging on PC and can get the requested data. When debugging the real phone in the mobile phone Wechat, the request to return fail, immediately is noted immediately, without any delay. It seems that no request was made directly on fail at all.

however, if you "turn on debugging" in the mobile phone Wechat, you can send the request successfully.

what"s going on?

< hr >

Update: solved.
the reason is unknown.
the solution is to play a game of PUBG and test it again when he comes back and be surprised to find out. Where is the cache? However, I have previously tried to clear the cache invalidation in the PC development tool.


should be a domain name verification problem. If your domain name does not meet the domain name regulations of Mini Program (must be https, cannot be with a port number, and cannot be an ip address), the domain name will be verified if it is not enabled for debugging, resulting in failure. In addition, if your domain name meets the requirements, but does not configure a valid domain name on the public platform, it will also cause failure.


Yes, generally speaking, you need to enable debugging


go to the community and ask the official code snippet

.
Menu