corda-checkers/webapp/src/App.js

32 lines
635 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() {
const [joke, setJoke] = useState(null);
2023-08-13 15:31:47 +02:00
useEffect(() => {
fetch('/api/badjokes')
.then((response) => response.json())
.then((data) => {
console.log(data.joke);
setJoke(data.joke);
})
.catch((err) => {
console.log(err.message);
});
2023-08-13 15:31:47 +02:00
}, []);
return (
<div className="App">
<header className="App-header">
<p>
Here is your joke: {joke ? <span>{joke}</span> : <span>Loading...</span>}
2023-08-13 15:31:47 +02:00
</p>
</header>
</div>
);
}
export default App;