I am not receiving any errors, but my profile is not showing up in my application.
import React, { useState, useEffect } from 'react';
const url = 'https://api.github.com/users/defunkt';
const Main = () => {
const [users, setUsers] = useState([]);
const getUsers = async () => {
const response = await fetch(url);
const usersData = await response.json();
setUsers(usersData);
};
useEffect(() => {
console.log("useEffect called");
getUsers();
}, []);
return (
<div>
<h3>Github Users</h3>
<ul className='users'>
{Array.isArray(users) && users.map((users) => {
const { id, login, avatar_url, html_url } = users;
return (
<li key={id}>
<img src={avatar_url} alt={login} />
<div>
<h4>{login}</h4>
<a href={html_url}>profile</a>
</div>
</li>
);
})}
</ul>
</div>
);
};
export default Main;
I just need a little widget that will take me to the git hub account. I know the API working I just can't pass it on to the use effect function.