Created
January 3, 2021 15:36
-
-
Save whisher/3a9ced47b911ee1b25b3b48415080caf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface UserDto { | |
login: string; | |
id: number; | |
node_id: string; | |
avatar_url: string; | |
gravatar_id: string; | |
url: string; | |
html_url: string; | |
followers_url: string; | |
following_url: string; | |
gists_url: string; | |
starred_url: string; | |
subscriptions_url: string; | |
organizations_url: string; | |
repos_url: string; | |
events_url: string; | |
received_events_url: string; | |
type: string; | |
site_admin: boolean; | |
name: string; | |
company: string; | |
blog: string; | |
location: string; | |
email: string | null; | |
hireable: boolean; | |
bio: string | null; | |
twitter_username: "ilwebdifabio"; | |
public_repos: number; | |
public_gists: number; | |
followers: number; | |
following: number; | |
created_at: string; | |
updated_at: string; | |
} | |
export const fetchUser = (key: string, searchUser: string): Promise<UserDto> => | |
fetch(`https://api.github.com/users/${searchUser}`).then((res) => res.json()); | |
export default function usePost(searchUser: string) { | |
return useQuery<UserDto, Error>(["user", searchUser], fetchUser,{ | |
enabled: searchUser, | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment