How to use the react-fetching-library.Client function in react-fetching-library

To help you get started, we’ve selected a few react-fetching-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marcin-piela / react-fetching-library / examples / simple-app / src / App.tsx View on Github external
api?: string;
};

const requestMiddleware: RequestInterceptor = () => async action => {
  await new Promise(resolve => setTimeout(resolve, 2000));

  return action;
};

const responseMiddleware: ResponseInterceptor = () => async (action, response) => {
  await new Promise(resolve => setTimeout(resolve, 2000));

  return response;
};

const client = Client({
  requestInterceptors: [requestMiddleware],
  responseInterceptors: [responseMiddleware],
});

type ApiResponse = {
  question: string;
};

const exampleAction = (): Action => ({
  method: 'GET',
  endpoint: 'https://private-34f3a-reactapiclient.apiary-mock.com/questions',
  api: 'test',
});

const examplePaginatedQuery = (page: number): Action => {
  return {

react-fetching-library

Simple and powerful API client for react. Use hooks or FACC's to fetch data in easy way. No dependencies! Just react under the hood.

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis