diff --git a/src/containers/BurgerBuilder/BurgerBuilder.js b/src/containers/BurgerBuilder/BurgerBuilder.js
index febf659..b60d1aa 100644
--- a/src/containers/BurgerBuilder/BurgerBuilder.js
+++ b/src/containers/BurgerBuilder/BurgerBuilder.js
@@ -19,16 +19,22 @@ const INGREDIENT_PRICE = {
class BurgerBuilder extends Component {
state = {
- ingredients: {
- meat: 0,
- cheese: 0,
- salad: 0,
- bacon: 0,
- },
+ ingredients: null,
totalPrice: 0,
purchasable: false,
purchasing: false,
loading: false,
+ error: false,
+ }
+
+ componentDidMount() {
+ axios.get('https://react-my-burger-e4645.firebaseio.com/ingredients.json') // remove .json to throw error
+ .then(res => {
+ this.setState({ ingredients: res.data });
+ })
+ .catch(error => {
+ this.setState({ error: true});
+ })
}
updatePurchaseState(ingredients) {
@@ -108,7 +114,7 @@ class BurgerBuilder extends Component {
}
};
- axios.post('/order.json', order)
+ axios.post('/order.json', order) // remove .json to throw error
.then(response => {
this.setState({ loading: false, purchasing: false }); // set purchasing: false can close Order Summary dialog
})
@@ -126,11 +132,29 @@ class BurgerBuilder extends Component {
disabledInfo[key] = disabledInfo[key] <= 0;
}
- let orderSummary =
Ingredients can't be loaded!
: