Skip to content

Instantly share code, notes, and snippets.

@simon-saliba
Last active January 23, 2021 15:47
Show Gist options
  • Save simon-saliba/793a9b3292e3d1012336ef024f60c601 to your computer and use it in GitHub Desktop.
Save simon-saliba/793a9b3292e3d1012336ef024f60c601 to your computer and use it in GitHub Desktop.
front-end App.js
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