From e163415c469e111df45e988dec231e35576ed2bc Mon Sep 17 00:00:00 2001 From: "Masaharu.Kato" Date: Thu, 5 Jun 2025 15:17:14 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AB=E3=83=86=E3=82=B4=E3=83=AA=E5=88=A5?= =?UTF-8?q?=E3=81=AE=E4=BB=AEAPI=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/services/api.ts | 23 +++++++++++++++++++++-- frontend/src/types/types.ts | 6 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index 854e67f..658bee1 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -3,7 +3,7 @@ * バックエンドAPIとの通信を担当するモジュール * 認証、タスク管理などの機能を提供 */ -import { LoginCredentials, RegisterCredentials, AuthResponse, Task, ToBuy } from '../types/types'; +import { LoginCredentials, RegisterCredentials, AuthResponse, Task, ToBuy, Stuff } from '../types/types'; import { AUTH_ERRORS, TASK_ERRORS } from '../constants/errorMessages'; // APIのベースURL - 環境変数から取得するか、デフォルト値を使用 @@ -171,6 +171,25 @@ export const toBuyApi = { }, } +export const stuffApi = { + getStuffs: async (category: string): Promise<{ stuff_array: Stuff[] }> => { + return { + "stuff_array": [ + { + "stuff_id": 6, + "stuff_name": "鯖", + "category": "魚" + }, + { + "stuff_id": 10, + "stuff_name": "鯛", + "category": "魚", + } + ] + } + } +} + /** * (サンプル,実際には不要) @@ -216,7 +235,7 @@ export const taskApi = { * @param task 作成するタスク情報(価格,作成日時、更新日時は除外) * @returns 作成されたタスク情報 */ - addStuff: async (task: Omit): Promise => { + addStuff: async (task: Omit): Promise => { const response = await fetch(`${API_BASE_URL}/api/tubuy/add`, { method: 'POST', headers: getHeaders(), diff --git a/frontend/src/types/types.ts b/frontend/src/types/types.ts index 42b1cfe..8d6a10c 100644 --- a/frontend/src/types/types.ts +++ b/frontend/src/types/types.ts @@ -29,6 +29,12 @@ export interface ToBuy { shop?: string, } +export interface Stuff { + stuff_id: number, + stuff_name: string, + category: string, +} + /** * ユーザー情報を表す型定義 * ユーザーの基本情報を管理