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.

12345678910111213141516171819
  1. import apiEndpoints from '../apiEndpoints';
  2. export const getAllProducts = async (
  3. pageIndex,
  4. category = 'All',
  5. filter = 'asc'
  6. ) => {
  7. const response = await fetch(
  8. `http://localhost:3000${apiEndpoints.products}?pageIndex=${pageIndex}&category=${category}&filterType=${filter}`
  9. );
  10. const data = await response.json();
  11. if (!response.ok) {
  12. throw new Error(data.message || 'Something went wrong!');
  13. }
  14. return data;
  15. };