网络请求
request
传参数说明
| 属性 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
method | string | GET | 是 | HTTP 请求方法 OPTIONS、GET、HEAD、POST、PUT、DELETE、TRACE、CONNECT |
url | string | 是 | 开发者服务器接口地址 | |
data | string/object/ArrayBuffer | 否 | 请求的参数 | |
header | object | 否 | 设置请求的 header,header 中不能设置 Referer。content-type 默认为 application/json | |
timeout | number | 否 | 超时时间,单位为毫秒 | |
success | function | 是 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码
dsBridge.call(
'request',
{
method:'POST',
url:'https://yide-apidev.kamwing.cn/graphql',
data: {
query: `query($args: ProductsInput!) {
products(args: $args) {
items {
id
name
cover_url
price
unit
}
}
}`,
variables: {
args: {
take: 10,
page: 1
}
}
},
header: {
'content-type': 'application/json' // 默认值
},
success (res) {
// 参照返回结果示例
}
}
)
返回结果示例
{
"code":1,
"data": {
"products": {
"items": [
{
"id": "0culaqnh0fodcyvu5l1odydi",
"name": "PVC皮革 编织纹皮革 格子皮料 箱包面料鞋革皮带面料礼盒沙发革",
"cover_url": "https://files-dev.for1688.cn/cbu01/ibank/O1CN01f8ASbY2LTu9ec3C3S_!!2211586579694-0-cib.jpg",
"price": "14.00-13.00",
"unit": "码"
},
{
"id": "16wzum8k52001zhe6w0jk15x",
"name": "【现货批发】拼色撞色双面革人造革PVC箱包革家居革餐桌垫鼠标垫",
"cover_url": "https://files-dev.for1688.cn/cbu01img/ibank/O1CN01loTzS72LTu9kqofVL_!!2211586579694-0-cib.jpg",
"price": "24.00-23.00",
"unit": "码"
}
//...
]
}
},
"msg":"success"
}