30 lines
373 B
JavaScript
30 lines
373 B
JavaScript
|
|
import {
|
||
|
|
message,
|
||
|
|
} from 'antd';
|
||
|
|
|
||
|
|
const fetch = (params) => {
|
||
|
|
const {
|
||
|
|
Api,
|
||
|
|
name,
|
||
|
|
fetchParams = {},
|
||
|
|
logic,
|
||
|
|
} = params;
|
||
|
|
|
||
|
|
Api[name](fetchParams).then(cb => {
|
||
|
|
const {
|
||
|
|
api_status,
|
||
|
|
} = cb;
|
||
|
|
|
||
|
|
if (api_status) {
|
||
|
|
logic(cb);
|
||
|
|
} else {
|
||
|
|
message.error();
|
||
|
|
}
|
||
|
|
}).catch(error => {
|
||
|
|
message.error();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
export {
|
||
|
|
fetch
|
||
|
|
}
|