微信小程序踩坑之一[wx.request]请求模式

最近在做小程序时,使用wx.request()方法请求时,

当使传输string类型时,一定要声明method请求模式为post,否则会一直报错,而不声明时默认为get,

已填坑 =,=

wx.request({
        method: "post",
        url: 'http://***.***.**/user/**/gainValidateCode', //仅为示例,并非真实的接口地址
        data: '{"appId": "1100****60349", "tim**mp": 1***9871, "ve**on": "1.0", "sign": "erwlk***lrjwlke", "mobile": "186*****", "validateWay": 1, "validateType": 2 }@#***018***60349'
        ,
        dataType:"json",
        header: {
          'content-type': 'application/json' // 默认值
        },
        success: function (res) {
          console.log(res.data)
        }
      })

猜你喜欢

转载自www.cnblogs.com/zhixi/p/9110966.html