import React from "react"; import Preview from "../elements/Preview"; import "../css/RandomPage.css" import SideBar from "../elements/SideBar"; import Tag from "../elements/Tag"; class RandomPage extends React.Component { constructor(props, context) { super(props, context); this.state = { videos: [], tags: [] }; } componentDidMount() { this.loadShuffledvideos(4); } render() { return (
Random Videos 4pc
Visible Tags:
{this.state.tags.map((m) => ( {m.tag_name} ))}
{this.state.videos.map(elem => ( ))}
); } shuffleclick() { this.loadShuffledvideos(4); } loadShuffledvideos(nr) { const updateRequest = new FormData(); updateRequest.append('action', 'getRandomMovies'); updateRequest.append('number', nr); // fetch all videos available fetch('/api/videoload.php', {method: 'POST', body: updateRequest}) .then((response) => response.json() .then((result) => { console.log(result); this.setState({ videos: result.rows, tags: result.tags }); })) .catch(() => { console.log("no connection to backend"); }); } } export default RandomPage;