corda-checkers/webapp/src/App.js

33 lines
764 B
JavaScript
Raw Normal View History

2023-08-13 15:31:47 +02:00
import './App.css';
import React, { useState, useEffect } from 'react';
function App() {
2023-08-21 18:05:19 +02:00
const [activeGames, setActiveGames] = useState(null);
2023-08-13 15:31:47 +02:00
useEffect(() => {
2023-08-21 18:05:19 +02:00
fetch('/api/activegames')
.then((response) => response.json())
2023-08-21 18:05:19 +02:00
.then((games) => {
console.log(games.ActiveGames.length);
console.log("games: " +games.ActiveGames);
setActiveGames(games.ActiveGames);
})
.catch((err) => {
console.log(err.message);
});
2023-08-13 15:31:47 +02:00
}, []);
return (
<div className="App">
<header className="App-header">
<p>
2023-08-21 18:05:19 +02:00
Here is list of your active games: {activeGames ? <span>{activeGames}</span> : <span>Loading...</span>}
2023-08-13 15:31:47 +02:00
</p>
</header>
</div>
);
}
export default App;