add config.json to configure api URL
Load config.json at startup Change-Id: I38df3611daed155c91fccdaf175df4b9778953ae
This commit is contained in:
parent
d42b04f049
commit
df050a5b51
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"apiURL": "http://localhost:8000"
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import { Provider } from "react-redux";
|
||||||
|
|
||||||
import "@patternfly/patternfly-next/patternfly.css";
|
import "@patternfly/patternfly-next/patternfly.css";
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
import { setConfig } from "./config/configActions";
|
import { getConfig } from "./config/configActions";
|
||||||
import * as Containers from "./containers";
|
import * as Containers from "./containers";
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
|
@ -13,12 +13,7 @@ class App extends Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
store.dispatch(
|
store.dispatch(getConfig()).then(() => this.setState({ isLoading: false }));
|
||||||
setConfig({
|
|
||||||
apiURL: "http://localhost:8000"
|
|
||||||
})
|
|
||||||
);
|
|
||||||
this.setState({ isLoading: false });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import axios from "axios";
|
||||||
import * as types from "./configActionsTypes";
|
import * as types from "./configActionsTypes";
|
||||||
|
|
||||||
export function setConfig(config) {
|
export function setConfig(config) {
|
||||||
|
@ -6,3 +7,13 @@ export function setConfig(config) {
|
||||||
config
|
config
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getConfig() {
|
||||||
|
return dispatch => {
|
||||||
|
return axios.get("/config.json").then(response => {
|
||||||
|
const config = response.data;
|
||||||
|
dispatch(setConfig(config));
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue