Skip to content

Instantly share code, notes, and snippets.

@whisher
Created January 3, 2021 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whisher/3a9ced47b911ee1b25b3b48415080caf to your computer and use it in GitHub Desktop.
Save whisher/3a9ced47b911ee1b25b3b48415080caf to your computer and use it in GitHub Desktop.
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