diff --git a/typing-app/docs/api-usage.md b/typing-app/docs/api-usage.md index 60881ee4..b27c7556 100644 --- a/typing-app/docs/api-usage.md +++ b/typing-app/docs/api-usage.md @@ -6,8 +6,22 @@ 例えば、 -```ts -// WIP +```tsx +import { client } from "@/libs/api"; + +async function SomePageToGetRanking() { + const { data, error } = await client.GET("/scores/ranking"); + + if (error) { + return
Error
; + } + + return ( +
+ ranking data: {JSON.stringify(data)} +
+ ); +} ``` のようにします。 diff --git a/typing-app/src/libs/api/index.ts b/typing-app/src/libs/api/index.ts new file mode 100644 index 00000000..1ff62cd4 --- /dev/null +++ b/typing-app/src/libs/api/index.ts @@ -0,0 +1,4 @@ +import createClient from "openapi-fetch"; +import { paths } from "./v1"; + +export const client = createClient({ baseUrl: process.env.API_URL });