发送http请求。任何http请求均需通过该API调用
options: 请求选项| 参数名 | 是否必选 | 备注 |
|---|---|---|
| url | 是 | 请求URL |
| data | 否 | 请求数据(get时,会作为query string自动加到URL之后) |
| dataType | 否 | 请求类型: 'json', 'jsonp'。默认为'json' |
| method | 否 | 请求的method: 'get', 'post' …, 默认为'get' |
| timeout | 否 | 请求的超时时间(ms), 默认为9000 |
| withCredentials | 否 | 跨域时,是否携带cookie。默认为true(仅dataType为'json'时有效) |
| headers | 否 | 自定义的请求头部 |
返回Promise,服务端返回的http数据通过then的回调获取
Tida.rop.call('ajax', {
url: 'http://gw.api.taobao.com/router/rest'
data: {
format: 'json'
},
}).then(function (data) {
console.log(data);
}, function (err) {
console.log(err);
});