diff --git a/public/config.json b/public/config.json new file mode 100644 index 0000000..06cfeb2 --- /dev/null +++ b/public/config.json @@ -0,0 +1,3 @@ +{ + "apiURL": "http://localhost:8000" +} diff --git a/src/App.js b/src/App.js index fb70c40..493ceca 100644 --- a/src/App.js +++ b/src/App.js @@ -4,7 +4,7 @@ import { Provider } from "react-redux"; import "@patternfly/patternfly-next/patternfly.css"; import store from "./store"; -import { setConfig } from "./config/configActions"; +import { getConfig } from "./config/configActions"; import * as Containers from "./containers"; class App extends Component { @@ -13,12 +13,7 @@ class App extends Component { }; componentDidMount() { - store.dispatch( - setConfig({ - apiURL: "http://localhost:8000" - }) - ); - this.setState({ isLoading: false }); + store.dispatch(getConfig()).then(() => this.setState({ isLoading: false })); } render() { diff --git a/src/config/configActions.js b/src/config/configActions.js index cc7958e..455e9d2 100644 --- a/src/config/configActions.js +++ b/src/config/configActions.js @@ -1,3 +1,4 @@ +import axios from "axios"; import * as types from "./configActionsTypes"; export function setConfig(config) { @@ -6,3 +7,13 @@ export function setConfig(config) { config }; } + +export function getConfig() { + return dispatch => { + return axios.get("/config.json").then(response => { + const config = response.data; + dispatch(setConfig(config)); + return response; + }); + }; +}