@alicloud/xconsole-rc-app-layout
v2.5.5
Published
> XConsole 请求包,基于 axios 封装
Downloads
69
Keywords
Readme
@alicloud/xconsole-base-service
XConsole 请求包,基于 axios 封装
Usage
import axios, { service, createService, getUploadSignature, createDefaultAxiosInstance } from '@alicloud/xconsole-base-service';
APIs
axios
service([data[, config]])
创建一个 service 实例
|Param|Type|DefaultDescription|
|-----|----|-----------|
|data |object
||
|config|object
||
await service({
action: 'product1',
product: 'action1',
params: {
RegionId: 'cn-hangzhou',
InstanceId: 'xxx-142534'
},
}, {
ignoreError: '',
data: configData = {},
params: configParams = {},
axiosInstance: null,
requestConfig: {
url: '' // required
}
});
createService(product, action[, transformConfig])
柯里化实现的 service 工厂函数
|Param|Type|Description|
|-----|----|-----------|
|product|string
||
|action|string
||
|transformConfig|function(config)
|修改 config |
const customService = createService(product, action, transformConfig);
customService(params, config);
getUploadSignature(bucketName, region, objectName[, options])
获取上传接口签名
|Param|Type|Description|
|-----|----|-----------|
|bucketName|string
||
|region|string
||
|objectName|string
||
|options|object
|{ extra: {}, ignoreError: false }
extra => axios requestConfig|
const sign = getUploadSignature('bucketName', 'cn-hangzhou', 'objectName', {
extra: {},
ignoreError: false
})
createDefaultAxiosInstance([instanceConfig])
创建一个 axios 实例
|Param|Type|Description|
|-----|----|-----------|
|instanceConfig|object
|axios config|
const ins = createDefaultAxiosInstance({
headers: {},
//...
});
// ins has axios instance methods
ins.request({
url: '/your/path', // required
method: 'get',
params: {}
});