diff options
| -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)), ) |
