refactor useProfile and useChannelProfile hooks

This commit is contained in:
Ren Amamiya
2023-04-27 10:28:07 +07:00
parent 8cadb7467f
commit 6918660a5c
24 changed files with 137 additions and 195 deletions

View File

@@ -0,0 +1,14 @@
import useSWR from 'swr';
const fetcher = (url: string) => fetch(url).then((r: any) => r.json());
export const useProfile = (pubkey: string) => {
const { data, error } = useSWR(`https://rbr.bio/${pubkey}/metadata.json`, fetcher);
if (error) {
return error;
}
if (data) {
return JSON.parse(data.content);
}
return null;
};