mirror of
https://github.com/diced/zipline.git
synced 2025-12-20 22:33:47 -08:00
17 lines
342 B
TypeScript
Executable File
17 lines
342 B
TypeScript
Executable File
import useSWR from 'swr';
|
|
|
|
const f = async () => {
|
|
const res = await fetch('/api/user/avatar');
|
|
if (!res.ok) return null;
|
|
|
|
const r = await res.text();
|
|
return r;
|
|
};
|
|
|
|
export default function useAvatar() {
|
|
const { data, mutate } = useSWR('/api/user/avatar', f, {
|
|
refreshInterval: 300000,
|
|
});
|
|
return { avatar: data, mutate };
|
|
}
|