import {Component} from 'react'; import request from '../scripts/requests'; class Connect extends Component { constructor(props) { super(props); this.queryParams = new URLSearchParams(window.location.search); const game_id = this.queryParams.get('gameId'); localStorage.setItem('gameId', game_id); } getToken() { return this.queryParams.get('token'); } getGameId() { return localStorage.getItem('gameId'); } componentDidMount() { document.title = "Подключиться к игре"; request("attend_game", { game_id: this.getGameId(), attend_token: this.getToken() }, (response) => { localStorage.setItem("token", response.token); window.location.href = "/new_game?gameId=" + this.getGameId() }) } render() { return
} } export default Connect;