Fetch

发送 HTTP(S) 请求的接口

接口说明:

static fetch(url, params)

参数

url String

请求的URL

params JSON对象

method:"POST",//可选参数,默认为 POST
headers:{},// 可选参数
body:{},//可选参数
timeout:,//不建议自行设置此值,建议省略,会使用框架默认值
isSOA2:,//默认为true,非 SOA2 的 HTTP(S) 服务才需要设置为 false,SOA2 的服务直接忽略即可
sequenceId:,//用来唯一标识一次网络请求,调用cancel时需传入,不调用cancel不用传

示例:

fetch('http://gateway.m.uat.qa.nt.ctripcorp.com/restapi/soa2/10612/GetMainMsgList', {
    body:{
    'ChannelType': "APP",
       'contentType':'json'
    }
  })
  .then((res) =
>
 {
    alert('response:' + JSON.stringify(res));
  })
  .catch((error) =
>
 {
    alert('error:' + JSON.stringify(error));
  });

static cancelFetch(url, params)

参数

url String

请求的URL

params JSON对象

{
sequenceId:,//用来唯一标识一次网络请求,传入fetch时传的sequenceId,必传
}

示例:

cancelFetch('http://gateway.m.uat.qa.nt.ctripcorp.com/restapi/soa2/10612/GetMainMsgList', {
    body:{
    'sequenceId': "72164781264"
    }
  })

results matching ""

    No results matching ""