From 45136aa1d6bb92be89c384fec9fad7d36682f470 Mon Sep 17 00:00:00 2001 From: JP1998 Date: Tue, 9 Apr 2019 17:03:04 +0200 Subject: [PATCH] Fix a bug which crashes the site when there is no internet connection In case there is no internet connection axios will not return a response object with the error after a request. Since we still tried to access said object the website crashed when there was no internet connection. --- pages/tournament.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pages/tournament.js b/pages/tournament.js index 6874c08..cae6a93 100644 --- a/pages/tournament.js +++ b/pages/tournament.js @@ -392,7 +392,11 @@ class Main extends React.Component { this.setState({ status : response.status, tournament : convertTournament(response.data)}); }) .catch((err) => { - this.setState({ status : err.response.status }); + if(err.response) { + this.setState({ status : err.response.status }); + } else { + this.setState({ status : -1 }); + } }); }