Professional Documents
Culture Documents
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
d. Open the browser with URL and verify the output as shown below.
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
b. Create new JavaScript file called Header.js file inside Components directory.
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
function Profile() {
const [git, setGit] = useState({
data:{},
repoitories:[],
loading:true,
error:''
})
useEffect(() => {
let mounted = true
async function fetchData(){
if(mounted){
try {
const profile = await
fetch('https://api.github.com/users/GITHUB_USERNAME');
const profileJSON = await profile.json();
if(profileJSON){
const repos = await
fetch(profileJSON.repos_url);
const repoJSON = await repos.json();
console.log(repoJSON)
setGit({
...git,
data:profileJSON,
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
}
}
}
fetchData()
return function cleanup() {
mounted = false
}
}, [])
if(git.loading || git.error){
return <div>{git.loading ? 'Loading...' :
git.error}</div>;
}
const items=[
{label:'html_url',value:<Link url={git.data.html_url}
title='Github URL'/>},
{label:'respos_url',value:git.data.repos_url},
{label:'name:',value:git.data.name},
{label:'location',value:git.data.location},
{label:'email:',value:git.data.email},
{label:'public_repos:',value:git.data.public_repos},
{label:'created_at',value:git.data.created_at}
]
const projects=git.repoitories.map(respository=>({
label:respository.name,
value:<Link url={respository.html_url} title='Github
URL' />
}))
return (
<ProfileWrapper>
<Avatar className="Profile-avatar"
src={git.data.avatar_url}></Avatar>
<List title='Profile' items={items}/>
<List title='Projects' items={projects}/>
</ProfileWrapper>
)
}
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved
function App() {
return (
<div className='App'>
<Header/>
<Profile/>
</div>
);
}
Copyright © 2022, Proton Expert Systems & Solutions. All rights reserved