refactor
parent
5b0de19ae4
commit
b67e204a7e
|
@ -1,21 +1,19 @@
|
|||
import * as types from "./actionTypes";
|
||||
import * as api from "./api";
|
||||
import api from "./api";
|
||||
import {
|
||||
beginApiCall,
|
||||
apiCallError
|
||||
} from "../../redux/actions/apiStatusActions";
|
||||
|
||||
export function loadSystemDateTime() {
|
||||
return function (dispatch) {
|
||||
return async function (dispatch) {
|
||||
dispatch(beginApiCall());
|
||||
return api
|
||||
.getSystemDateTime()
|
||||
.then((data) => {
|
||||
dispatch({ type: types.LOAD_SYSTEM_DATETIME_SUCCESS, payload: data });
|
||||
})
|
||||
.catch((error) => {
|
||||
dispatch(apiCallError(error));
|
||||
throw error;
|
||||
});
|
||||
try {
|
||||
const data = await api.getSystemDateTime();
|
||||
dispatch({ type: types.LOAD_SYSTEM_DATETIME_SUCCESS, payload: data });
|
||||
} catch (error) {
|
||||
dispatch(apiCallError(error));
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { handleResponse, handleError } from "../../api/apiUtils";
|
||||
const baseUrl = process.env.REVERSE_PROXY_API_URL + "/system";
|
||||
|
||||
export function getSystemDateTime() {
|
||||
return fetch(`${baseUrl}/datetime`).then(handleResponse).catch(handleError);
|
||||
}
|
||||
const getSystemDateTime = () =>
|
||||
fetch(`${baseUrl}/datetime`).then(handleResponse).catch(handleError);
|
||||
|
||||
export default {
|
||||
getSystemDateTime
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue