diff options
Diffstat (limited to 'src/hooks/APIClient.ts')
-rw-r--r-- | src/hooks/APIClient.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/hooks/APIClient.ts b/src/hooks/APIClient.ts index d3c4542..015191c 100644 --- a/src/hooks/APIClient.ts +++ b/src/hooks/APIClient.ts @@ -6,9 +6,11 @@ type Response<T> = responseInterface<T, Error>; const fetcher = (endpoint: string) => get(endpoint).then(response => response.data); - -export const useUser = (id: string): Response<User> => { - return useSWR(id && `/users/${id}`, fetcher); +export const useUser = (username: string | null): Response<User> => { + return useSWR( + username && `/users?username=${username}`, + (url: string) => get(url).then(response => response.data[0]) + ); }; export const useEvents = (): Response<Event[]> => { |