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.
This commit is contained in:
JP1998 2019-04-09 17:03:04 +02:00
parent 6035da058e
commit 45136aa1d6
1 changed files with 5 additions and 1 deletions

View File

@ -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 });
}
});
}