class List extends React.Component { state = { queries: [] } getAllQueries = () => { var apicall = sspglobals.apiurl + "?cmd=" + "getqueries" + "&hash=" + this.props.user.hash; fetch(apicall).then((response) => { if (response.ok) return response.json(); else throw new Error("Error beim API Aufruf!"); }) .then((json) => { if (json.result.length == 0) { this.setState({queries: []}); return; } if (json.result[0][0] == "error") { alert(json.result[0][1]); this.setState({queries: []}); return; } if (json.result[0][0] == "getqueries") { const rr = json.result.map(arr =>{return {id: arr[1], func: arr[2]}}); this.setState({queries: rr}); } }) .catch((err) => { console.log(err); }); } componentDidMount = () => { this.getAllQueries(); } renderTable = () => { if (this.state.queries.length == 0) return
No queries yet...
return (| id | function | action |
|---|