27 lines
677 B
TypeScript
27 lines
677 B
TypeScript
import {
|
|
Products,
|
|
PaginationMeta,
|
|
Product,
|
|
CategoriesResponse,
|
|
} from '@interfaces';
|
|
import { apiClient } from '@services';
|
|
|
|
export interface GetProductsResponse {
|
|
products: Products[];
|
|
meta: PaginationMeta;
|
|
}
|
|
|
|
export const getProductsApi = async (): Promise<GetProductsResponse> => {
|
|
return await apiClient.get<GetProductsResponse>(`/products`);
|
|
};
|
|
|
|
export const getProductDetailsApi = async (
|
|
productId: string,
|
|
): Promise<Product> => {
|
|
return await apiClient.get<Product>(`/products/${productId}`);
|
|
};
|
|
|
|
export const getCategoriesApi = async (): Promise<CategoriesResponse> => {
|
|
return await apiClient.get<CategoriesResponse>(`/categories/selected`);
|
|
};
|