调用 Web Service API
1. 安装与引用 SDK
$ yarn add kunlun-ws-api --registry http://172.30.3.107:8082/repository/npm_group/
TIP
kunlun-ws-api 源码地址: https://192.168.1.118:1443/svn/KunLun/Client/kunlun-ws-api
2. 场景1:在 model effects 中调用
import { manageApi } from 'kunlun-ws-api';
export default {
namespace: 'app',
state: {
// ...
},
reducers: {
// ...
},
effects: {
* getSystemTime(action, { put, call, select }) {
let manageGetSystemTimeSuccess = false;
let systemTime = null;
try {
const { result, errmsg, errcode } = yield call(manageApi.manageGetSystemTime);
if (errcode === '2000') {
manageGetSystemTimeSuccess = true;
systemTime = result;
} else {
// error handling
}
} catch (error) {
// error handling
}
if (manageGetSystemTimeSuccess !== true) return;
// ...
},
},
subscriptions: {
},
};