選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

productRequest.js 441B

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. };