diff --git a/frontend/code/src/components/Home/assets/Table.tsx b/frontend/code/src/components/Home/assets/Table.tsx index 3133aab..3d51338 100644 --- a/frontend/code/src/components/Home/assets/Table.tsx +++ b/frontend/code/src/components/Home/assets/Table.tsx @@ -1,58 +1,67 @@ import { Trophy } from './Trophy' import { useState,useEffect } from 'react' -const [users, setUsers] = useState([]) -useEffect( () => { - const fetchdata = async() =>{ - let response = await fetch(`https://randomuser.me/api/`) - let data = await response.json() - console.log(data) - if (data) - setUsers((users) => ...users , data) - } - fetchdata().catch(console.error) -},[]) + + export const Table = () => { + const [users, setUsers] = useState([]) + useEffect( () => { + + const fetchdata = async() =>{ + for (let i = 0 ; i < 10 ; i++) + { + let response = await fetch(`https://randomuser.me/api/`) + let data = await response.json() + if (data.results && data.results.length > 0) { + const newUser = data.results[0]; + setUsers((oldUsers : any) => [...oldUsers, newUser]); + console.log(newUser) + } + } + } + + fetchdata().catch(console.error) + + },[]) return ( -
- - - - - - - - - - - - - - - - - -
PlaceUserScore
-
-
- - - -
-
-
-
-
- Avatar Tailwind CSS Component -
-
-
wadie
-
- 24 -
-
- ) +
+ + + + + + + + + + {users.map((x: any, index: number) => ( + + + + + + ))} + +
PlaceUserScore
+
+
+ +
+
+
+
+
+ Avatar Tailwind CSS Component +
+
+
{x.name.first}
+
24
+
+ ); } \ No newline at end of file