Skip to content

Commit

Permalink
Merge pull request #48 from su-its/feat/frontend/create-api-client
Browse files Browse the repository at this point in the history
feat[typing-app]: バックエンドAPIを呼ぶクライアントを作成
  • Loading branch information
KinjiKawaguchi authored Mar 31, 2024
2 parents 62dfc5d + b18a939 commit 3a5e372
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 16 additions & 2 deletions typing-app/docs/api-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <div>Error</div>;
}

return (
<div>
ranking data: {JSON.stringify(data)}
</div>
);
}
```

のようにします。
Expand Down
4 changes: 4 additions & 0 deletions typing-app/src/libs/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import createClient from "openapi-fetch";
import { paths } from "./v1";

export const client = createClient<paths>({ baseUrl: process.env.API_URL });

0 comments on commit 3a5e372

Please sign in to comment.