rxai-api-core
v1.0.3
Published
```json lines "rxai-api-core": "^1.0.0" ```
Downloads
3
Readme
1、package.json引入对应的包,如下:
"rxai-api-core": "^1.0.0"
2、入口如app.ts全局设置请求工厂实现
import HttpUtils from 'rxai-api-core/dist/HttpUtils';
// 其中RequestImpl是由用户自己编写实现类,详见第3步操作
import RequestImpl from '@/utils/RequestImpl';
HttpUtils.setFactory(() => new RequestImpl());
3、RequestImpl示例如下(icejs的request举例,也可为axios,只要能够实现网络请求)
import { request } from 'ice';
import { RequestParam } from 'rxai-api-core/dist/AbstractApi';
class RequestImpl {
requestParam: RequestParam;
init(requestParam: RequestParam) {
this.requestParam = requestParam;
}
start() {
return request({
url: this.requestParam.path,
method: this.requestParam.method,
data: this.requestParam.data,
responseType: this.requestParam.responseType,
headers: {
'Content-Type': 'application/json',
},
});
}
}
export default RequestImpl;