master
Tudor Stanciu 2020-05-06 16:15:48 +03:00
parent 5b0de19ae4
commit b67e204a7e
2 changed files with 15 additions and 14 deletions

View File

@ -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) {
.catch((error) => {
dispatch(apiCallError(error)); dispatch(apiCallError(error));
throw error; throw error;
}); }
}; };
} }

View File

@ -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
};