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

View File

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