diff --git a/frontend/src/scripts/index.js b/frontend/src/scripts/index.js index 237146f..c61bf91 100644 --- a/frontend/src/scripts/index.js +++ b/frontend/src/scripts/index.js @@ -51,10 +51,12 @@ class Main extends Component { this.setState({login_status: json}) }) fetch(addr_prefix + "/api/cart/delivery").then(resp => resp.json()).then(json => { - this.setState({ - cart: [...this.state.cart, {"name": "Doprava na " + json, "id": 2, "price": delivery_cost, "locked": true, "quantity": 1}], - delivery: json, - }) + if (json){ + this.setState({ + cart: [...this.state.cart, {"name": "Doprava na " + json, "id": 2, "price": delivery_cost, "locked": true, "quantity": 1}], + delivery: json, + }) + } }) if(window.location.search){ let searchParams = new URLSearchParams(window.location.search);