html52.com
我爱小程序-开发者交流社区

request问题

问题模块
API和组件

第一次打开小程序request请求不成功 , 第二次打开小程可以访问成功

模拟器上不会出现问题, 真机上会有,不管是android还是ios,

第一次错误提示 : request : fail url not in domain list


代码 :


   wx.login({

      success : function(code){

        wx.getUserInfo({

          success : function(user){

            var userCod = code.code;

            var nickName = user.userInfo.nickName

            wx.showModal({

              title: 'title',

              content: 'code = ' + code.code +"user = " +user.userInfo.nickName,

              showCancel : false,

              success : function(res){

                if(res.confirm){

                  wx.request({

                    url: 'http://***.com/hepcws/v2/restws/****',

                    data: {

                      "appid": "********e5be52",

                      "secret": "******cb393a9de",

                      "js_code": userCod,

                      "nickName": nickName

                    },

                    method: "POST",

                    header: {

                      'content-type': 'application/json'

                    },

                    success: function (res) {

                      wx.showToast({

                        title: 'success : ' + res,

                      })

                      that.setData({

                        userInfo: user.userInfo

                      })

                    },

                    fail: function (res) {

                      wx.showToast({

                        title: 'fail = ' + res.errMsg,

                      })

                    },

                    complete: function (res) {


                    }

                  })

                }

              }

            })

          }

        })

      }

    })


网友回复

周亮:

由于是http的测试环境域名,没有在公众平台配置,只有第一次请求的时候出现这个错误 ,我把小程序关闭,第二次请求又不会出现这个问题


猜猜我是谁:

是否在公众平台配置了request合法域名?

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付