Last active
January 23, 2021 15:47
-
-
Save simon-saliba/793a9b3292e3d1012336ef024f60c601 to your computer and use it in GitHub Desktop.
front-end App.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
function App() { | |
const [message, setMessage] = useState(''); | |
// Send a request to the server on port 8080 to retrieve message | |
useEffect(() => { | |
fetch('http://localhost:8080/hello') | |
.then(response => { | |
return response.json(); | |
}) | |
.then(res => { | |
setMessage(res); | |
}) | |
}); | |
return ( | |
<div className="App"> | |
<header className="App-header"> | |
<img src={logo} className="App-logo" alt="logo" /> | |
<p> | |
{message} | |
</p> | |
</header> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment