| 123456789101112131415161718 |
- import { SingleProductResponse } from '../../utils/interface/productInterface';
- import apiEndpoints from '../apiEndpoints';
-
- export const getProductData = async (
- productId: string
- ): Promise<SingleProductResponse> => {
- const response = await fetch(
- `http://localhost:3000${apiEndpoints.products}/${productId}`
- );
-
- const data: SingleProductResponse = await response.json();
-
- if (!response.ok) {
- throw new Error(data.message || 'Something went wrong!');
- }
-
- return data;
- };
|