# sendNormalRequest
请求不经过中台接口
# 调用方式
sendNormalRequest(options, otherOptions = { isShowLoading: true, processCallback: () => {} })
1
返回 Promise,使用 then/catch 或 await 处理结果。
# 请求参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| options | Object | Y | — | Weex stream.fetch 请求选项,需提供 url |
| options.url | String | Y | — | HTTP 请求地址 |
| options.method | String | N | 'GET' | 请求方式,自动转换为大写 |
| options.headers | Object | N | { Content-Type: application/json } | 请求头,可覆盖默认头 |
| otherOptions | Object | N | 见说明 | 其他请求配置 |
| otherOptions.isShowLoading | Boolean | N | true(省略整个对象时) | 是否展示 Loading |
| otherOptions.processCallback | Function | N | 空函数 | 兼容保留,当前实现不调用此回调 |
# 接口调用示例
this.$bridge.sendNormalRequest({ url: 'https://example.com/api', method: 'GET' }, { isShowLoading: false })
.then(res => {
console.log(res)
})
.catch(error => {
console.error(error)
})
1
2
3
4
5
6
7
2
3
4
5
6
7
# 返回参数
返回 Promise。成功时 resolve stream 响应的 data,本方法不保证再包一层 { data: ... }。response.ok 为 false 时 reject 响应对象,执行异常或无效响应时 reject 错误。
# 注意事项
省略整个 otherOptions 时默认显示 Loading;显式传 {} 时 isShowLoading 为 undefined,不显示 Loading。