微信小程序request请求之GET跟POST的区别

1、GET

例子:

wx.request({
  url: 'test.php', //仅为示例,并非真实的接口地址
  data: {
     x: '' ,
     y: ''
  },
  header: {
      'content-type': 'application/json' // 默认值
  },
  success: function(res) {
    console.log(res.data)
  }
})

首先这个是GET请求,虽然data传了值,跟ajax的POST请求很像,但它就是GET请求。

2、POST

wx.request( {  
  url: "https://text.php", 
  header: {  
    "Content-Type": "application/x-www-form-urlencoded"  
  },  
  method: "POST",  
  data: {
    x:"",
    y:""
  },  
  success: function(res) { 

  }  
})  

微信小程序的POST请求需要改变红色字体这2个地方