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

Leave faction

parent 4a2de0aa
No related branches found
No related tags found
2 merge requests!31Development,!28Routing
......@@ -48,7 +48,31 @@ export default class GameView extends React.Component {
.catch(error => console.log(error));
}
handleLeaveFaction = e => {};
handleLeaveFaction = e => {
let token = sessionStorage.getItem("token");
fetch(
`${process.env.REACT_APP_API_URL}/faction/leave/${
this.state.gameInfo.id
}`,
{
method: "DELETE",
headers: {
Authorization: "Bearer " + token
}
}
)
.then(res => {
if (res.ok) {
return res.json();
} else {
throw Error(res.statusText);
}
})
.then(res => {
alert(res.message);
})
.catch(error => console.log(error));
};
render() {
const initialPosition = [this.state.lat, this.state.lng];
......
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