import { Component } from "react";
import { Element } from "./Element";

export class Liste extends Component {
    constructor(props) {
        super(props);
        this.state = {
            games: []
        }
    }
    componentDidMount() {
        const url = "http://localhost:1235/party/get?DBlimit=10&DBsort[start]=-1";
        fetch(url)
            .then(response => response.json())
            .then(json => {
                this.setState({ games: json });
                console.log(json);
            })
    }
    render() {
        const { games } = this.state;
        return (
            <div class="list-group">
                {games.map((game, index) =>
                    <Element index={index} game={game} />
                )}
            </div>
        )
    }
}