From 925587c1b21e9154c4b5dfc74d33ab4680235825 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 7 Feb 2022 16:24:33 +0200 Subject: Fix API types --- src/Editor.tsx | 4 +++- 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. 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, diff --git a/src/api.ts b/src/api.ts index c486acc..226e213 100644 --- a/src/api.ts +++ b/src/api.ts @@ -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 { readonly type: "success" data: D @@ -77,7 +71,7 @@ const postRequest = async ({ baseUrl, path, body }: BasePostRequest, } } -export const useExamples = () => mapSWRResult( +export const useExamples = () => mapSWRResult( useSWR(ExampleApi.ListRequest.path, fetcher(EXAMPLE_API_URL)), ) -- cgit v1.3