diff options
Diffstat (limited to 'src/hooks')
-rw-r--r-- | src/hooks/APIClient.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/hooks/APIClient.ts b/src/hooks/APIClient.ts index 68413b0..1793843 100644 --- a/src/hooks/APIClient.ts +++ b/src/hooks/APIClient.ts @@ -1,5 +1,6 @@ import useSWR, { responseInterface } from 'swr'; import { User, Poll, Feedback } from 'which-types'; +import axios from 'axios'; import { get } from '../requests'; type Response<T> = responseInterface<T, Error>; @@ -24,3 +25,21 @@ export const useFeed = (): Response<Poll[]> => { export const useFeedback = (): Response<Feedback[]> => { return useSWR('/feedback', fetcher); }; + +export interface Release { + url: string; + description: string; + version: string; + name: string; +} + +export const usePatchNotes = (): Response<Release> => { + const fetchRelease = () => axios.get('https://api.github.com/repos/which-ecosystem/which/releases/latest') + .then(({ data }) => ({ + name: data.name, + url: data.html_url, + version: data.tag_name, + description: data.body + })); + return useSWR('/patchnotes', fetchRelease, { revalidateOnFocus: false }); +}; |