Skip to main content

网络请求

request

传参数说明

属性类型默认值是否必填描述
methodstringGETHTTP 请求方法 OPTIONS、GET、HEAD、POST、PUT、DELETE、TRACE、CONNECT
urlstring开发者服务器接口地址
datastring/object/ArrayBuffer请求的参数
headerobject设置请求的 header,header 中不能设置 Referer。content-type 默认为 application/json
timeoutnumber超时时间,单位为毫秒
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数
completefunction接口调用结束的回调函数(调用成功、失败都会执行)

示例代码

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"
}