This is a simple gihub User Profile UI built with React, Axios, React-Router and Tailwind CSS. It allows users to search github user profile by their profile name.
- Search your gihub profile (by username) using Github API
- My github profile and Bio using Github API
- My git repos using Github API
Before you begin, ensure you have the following installed on your local machine:
-
Clone the repository:
git clone https://github.com/Yogesh-chiluka/githubUserProfile.git cd githubUserProfile
-
Install dependencies:
npm install
-
Start the development server:
npm start
The app should now be running on
http://localhost:3000
.
-
Get your github profile:
- Click on search box and enter your github profile name.
-
To get my Profile and Repos:
- Click on Profile and Repositories to get my profile, bio and repos.
// getData function to get my Profile and Repos
export function getData(data) {
return axios.get(data)
.then(function (response) {
return response.data; // <-- returned to getReasonTypes
})
.catch(function (error) {
console.log(error);
throw error;
});
}
// Loader function for my profile data
export const Loader = () => {
let fetch_data = getData("https://api.github.com/users/Yogesh-chiluka")
console.log("loading data");
console.log(fetch_data)
return fetch_data
};
// Loader function for my repos data
export const Loader = () => {
let fetch_data = getData("https://api.github.com/users/Yogesh-Chiluka/repos")
console.log("loading data");
console.log(fetch_data)
return fetch_data
};
const fetchData = async () => {
setLoading(true);
setError(null);
try {
const response = await axios.get(`https://api.github.com/users/${query}`);
setUserData(response.data);
console.log(response.data)
fetchReposData()
} catch (error) {
setError(error);
} finally {
setLoading(false);
}
};
const fetchReposData = async () =>{
setLoading(true);
setError(null);
try {
const response = await axios.get(`https://api.github.com/users/${query}/repos`);
setReposData(response.data);
console.log(response.data)
} catch (error) {
setError(error);
} finally {
setLoading(false);
}
}
useEffect(() => {
if (query) {
const debounceFetch = setTimeout(fetchData, 500); // Debounce for 500ms
return () => clearTimeout(debounceFetch);
}
}, [query]); // Effect depends on query
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Make your changes.
- Commit your changes (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Create a new Pull Request.