import apiEndpoints from '../apiEndpoints'; interface ProductsResponse { message: string; product: object; productCount: number; next: string; previous: string; } export const getAllProducts = async ( pageIndex: number, category = 'All', filter = 'asc' ): Promise => { const response = await fetch( `http://localhost:3000${apiEndpoints.products}?pageIndex=${pageIndex}&category=${category}&filterType=${filter}` ); const data: ProductsResponse = await response.json(); if (!response.ok) { throw new Error(data.message || 'Something went wrong!'); } return data; };