Download src/api/productApi.ts from Jessedbrown/daisy-client: direct link, hf CLI and curl.
- Browser
- Download file 868 Bytes
-
https://huggingface.co/Jessedbrown/daisy-client/resolve/main/src/api/productApi.ts
- Command line
-
hf download hf://Jessedbrown/daisy-client/src/api/productApi.ts
-
curl -L -o productApi.ts https://huggingface.co/Jessedbrown/daisy-client/resolve/main/src/api/productApi.ts
868 Bytes
| import { BackendApiResponse, SearchFilters, SearchResult } from '@/types'; | |
| import { apiClient } from './client'; | |
| export const productApi = { | |
| searchProducts: async (filters: SearchFilters): Promise<SearchResult> => { | |
| const params: Record<string, string | number> = {}; | |
| if (filters.query) params.query = filters.query; | |
| if (filters.page) params.page = filters.page; | |
| if (filters.limit) params.limit = filters.limit; | |
| const response = await apiClient.get<BackendApiResponse<SearchResult>>( | |
| '/products', | |
| { params } | |
| ); | |
| return response.data.data; | |
| }, | |
| // Add product to closet | |
| addToCloset: async (productId: string): Promise<{ message: string }> => { | |
| const response = await apiClient.post< | |
| BackendApiResponse<{ message: string }> | |
| >(`/products/${productId}/add-to-closet`); | |
| return response.data.data; | |
| }, | |
| }; | |