diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-02-07 16:24:33 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-02-07 16:24:33 +0200 |
| commit | 925587c1b21e9154c4b5dfc74d33ab4680235825 (patch) | |
| tree | 56b7f9c3d89574110a65fa37e44dd4d8ba4c3af3 | |
| parent | e395c14a4159edcdb6203664e500d4adaa37bcac (diff) | |
Fix API types
| -rw-r--r-- | src/Editor.tsx | 4 | ||||
| -rw-r--r-- | src/api.ts | 8 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/Editor.tsx b/src/Editor.tsx index 2fff5b9..b0441d7 100644 --- a/src/Editor.tsx +++ b/src/Editor.tsx @@ -35,7 +35,9 @@ const Editor = () => { An unexpected error occurred while loading examples. See console for details. </div> case "success": { - const options = examples.data.map(example => ({ value: example.content, label: example.title })) + const options = examples.data.examples.map(example => ({ + value: example.content, label: example.title, + })) const customStyles = { option: (styles: any) => ({ ...styles, @@ -12,12 +12,6 @@ const fetcher = (baseUrl: string) => (path: string) => fetch(`${baseUrl}${path}` throw err }) -interface Example { - id: string - title: string - content: string -} - export interface APISuccess<D> { readonly type: "success" data: D @@ -77,7 +71,7 @@ const postRequest = async <R, D, E>({ baseUrl, path, body }: BasePostRequest<R>, } } -export const useExamples = () => mapSWRResult<Example[], Error>( +export const useExamples = () => mapSWRResult<ExampleApi.ListResponse.Body, Error>( useSWR(ExampleApi.ListRequest.path, fetcher(EXAMPLE_API_URL)), ) |
