カテゴリ別の仮API作成

dev-backend-tobuy
Masaharu.Kato 5 months ago
parent b3002ec297
commit e163415c46
  1. 23
      frontend/src/services/api.ts
  2. 6
      frontend/src/types/types.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<Task, 'userId'|'createdAt'|'price'|'buyDate'|'expirationDate'|'newAddition' >): Promise<Task> => {
addStuff: async (task: Omit<Task, 'userId' | 'createdAt' | 'price' | 'buyDate' | 'expirationDate' | 'newAddition'>): Promise<Task> => {
const response = await fetch(`${API_BASE_URL}/api/tubuy/add`, {
method: 'POST',
headers: getHeaders(),

@ -29,6 +29,12 @@ export interface ToBuy {
shop?: string,
}
export interface Stuff {
stuff_id: number,
stuff_name: string,
category: string,
}
/**
*
*

Loading…
Cancel
Save