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