corda-checkers/webapp/src/App.js

31 lines
613 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([]);
useEffect(() => {
fetch('/api/badjokes')
.then((response) => response.json())
.then((data) => {
console.log(data.joke);
setJoke(data.joke);
})
.catch((err) => {
console.log(err.message);
});
}, []);
return (
<div className="App">
<header className="App-header">
<p>
Here is your joke: {joke}
</p>
</header>
</div>
);
}
export default App;