# RequestTask

Start from base library version 1.4.0. Please remaining backward compatible.

Requests tasks over the network.

# Methods

# RequestTask.abort()

Aborts requesting tasks.

# RequestTask.onHeadersReceived(function callback)

Listens on HTTP Response Header event, which will be earlier than the request completion event.

# RequestTask.offHeadersReceived(function callback)

Un-listens on the HTTP Response Header event.

# Sample Code

const requestTask = wx.request({
  url: 'test.php', //This value for demonstration purposes only is not a real API URL.
  data: {
    x: '' ,
    y: ''
  },
  header: {
    'content-type': 'application/json'
  },
  success (res) {
    console.log(res.data)
  }
})
requestTask.abort() //Cancel requesting tasks
点击咨询小助手