You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

producDataRequest.ts 494B

123456789101112131415161718
  1. import { SingleProductResponse } from '../../utils/interface/productInterface';
  2. import apiEndpoints from '../apiEndpoints';
  3. export const getProductData = async (
  4. productId: string
  5. ): Promise<SingleProductResponse> => {
  6. const response = await fetch(
  7. `http://localhost:3000${apiEndpoints.products}/${productId}`
  8. );
  9. const data: SingleProductResponse = await response.json();
  10. if (!response.ok) {
  11. throw new Error(data.message || 'Something went wrong!');
  12. }
  13. return data;
  14. };