Skip to content
Snippets Groups Projects
Commit 7682ff6e authored by Joni Laukka's avatar Joni Laukka
Browse files

Show error to user if game state does not allow the user to leave faction

parent 4378e5d9
No related branches found
No related tags found
2 merge requests!31Development,!28Routing
...@@ -60,6 +60,7 @@ export default class GameView extends React.Component { ...@@ -60,6 +60,7 @@ export default class GameView extends React.Component {
handleLeaveFaction = e => { handleLeaveFaction = e => {
let token = sessionStorage.getItem("token"); let token = sessionStorage.getItem("token");
let error = false;
fetch( fetch(
`${process.env.REACT_APP_API_URL}/faction/leave/${ `${process.env.REACT_APP_API_URL}/faction/leave/${
this.state.gameInfo.id this.state.gameInfo.id
...@@ -72,11 +73,10 @@ export default class GameView extends React.Component { ...@@ -72,11 +73,10 @@ export default class GameView extends React.Component {
} }
) )
.then(res => { .then(res => {
if (res.ok) { if (!res.ok) {
return res.json(); error = true;
} else {
throw Error(res.statusText);
} }
return res.json();
}) })
.then(res => { .then(res => {
alert(res.message); alert(res.message);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment