awesome-compose/react-rust-postgres/frontend/src/App.js
Guillaume Lours 6f66b4a526
fix security issues on react-rust-postgres sample
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-03-12 19:45:38 +01:00

35 lines
858 B
JavaScript

import React, { useEffect, useState } from "react";
import logo from "./logo.svg";
import "./App.css";
function App() {
const [message, setMessage] = useState();
useEffect(() => {
fetch("/api/users")
.then((res) => res.json())
.then((res) => setMessage(`Hello with ${res.length} users`))
.catch(console.error);
}, [setMessage]);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>{message || "Loading..."}</p>
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;