LocChat/client/components/admin/_admin.jsx

24 lines
550 B
React
Raw Normal View History

2021-12-01 22:18:26 -05:00
import { useState, useContext, useEffect } from 'react';
import { ApiContext } from '../../utils/api_context';
export const Admin = () => {
const [users, setUsers] = useState([]);
const api = useContext(ApiContext);
useEffect(async () => {
const { users } = await api.get('/users');
setUsers(users);
}, []);
return (
<div className="p-4">
<h2 className="text-3xl">Users</h2>
{users.map((user) => (
2021-12-04 23:19:54 -05:00
<div key={user.id}>
{user.firstName} {user.lastName}
</div>
2021-12-01 22:18:26 -05:00
))}
</div>
);
};