mirror of
https://github.com/docker/awesome-compose.git
synced 2025-04-19 15:28:06 +02:00
Fix formatting of API response
Signed-off-by: Richard Crawley <richard.crawley@protonmail.com>
This commit is contained in:
parent
6531426a96
commit
a3a2d02aed
1 changed files with 6 additions and 1 deletions
7
react-rust-postgres/frontend/src/App.js
vendored
7
react-rust-postgres/frontend/src/App.js
vendored
|
@ -2,12 +2,17 @@ import React, { useEffect, useState } from "react";
|
|||
import logo from "./logo.svg";
|
||||
import "./App.css";
|
||||
|
||||
function formatUsers(users) {
|
||||
return `Users: ${users.map(user => user.login).join(", ")}`
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [message, setMessage] = useState();
|
||||
useEffect(() => {
|
||||
fetch("/api/users")
|
||||
.then((res) => res.json())
|
||||
.then((res) => setMessage(res.message))
|
||||
.then(formatUsers)
|
||||
.then(setMessage)
|
||||
.catch(console.error);
|
||||
}, [setMessage]);
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue