add config.json to configure api URL
Load config.json at startup Change-Id: I38df3611daed155c91fccdaf175df4b9778953ae
This commit is contained in:
parent
d42b04f049
commit
df050a5b51
3
public/config.json
Normal file
3
public/config.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"apiURL": "http://localhost:8000"
|
||||
}
|
@ -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() {
|
||||
|
@ -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;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user