asdfasdf
This commit is contained in:
parent
24f2988c76
commit
84ce41a32f
6 changed files with 89 additions and 19 deletions
23
src/components/repos.tsx
Normal file
23
src/components/repos.tsx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { useEffect, useState } from "react";
|
||||
|
||||
export default function Repos() {
|
||||
const [userInfo, setUserInfo] = useState({ public_repos: 0, followers: 0 });
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchUserInfo() {
|
||||
try {
|
||||
const response = await fetch("https://api.github.com/users/imnyang");
|
||||
const data = await response.json();
|
||||
setUserInfo({ public_repos: data.public_repos, followers: data.followers });
|
||||
} catch (error) {
|
||||
console.error("Error fetching user info:", error);
|
||||
}
|
||||
}
|
||||
|
||||
fetchUserInfo();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>{userInfo.public_repos}</>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue