小程序-wx.request POST请求,请求参数需要form-data形式

只要将wx.request的header中改为 ‘content-type’: ‘application/x-www-form-urlencoded’ 请求参数自然就变成了form-data形式

 

wx.request({
  url: 'test.php', //仅为示例,并非真实的接口地址
  data: {
    x: '',
    y: ''
  },
  header: {
    'content-type': 'application/x-www-form-urlencoded' //修改此处即可
  },
  success (res) {
    console.log(res.data)
  }
})

 

内容搬运来源:https://blog.csdn.net/weixin_44777433/article/details/103277495?spm=1001.2014.3001.5501

!!亲测有效

posted @ 2022-01-12 16:54  MiniDuck  阅读(869)  评论(0编辑  收藏  举报