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

dataRequest.ts 471B

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