Skip to content

API communication ICSHWI-10103

John Sparger requested to merge api-communication-ICSHWI-10103 into develop

This merge request adds:

  • Hooks and contexts for generating/getting an OpenAPI client (useCreateAPIClient and APIProvider)
  • Reentrance detection in useAsync (can be used to abort requests)
    • (Reentrance is when you call a function again before the last call to the function has finished)
    • (This happens, for example, when we issue a second API request to an endpoint before the first has returned a response)
  • A wrapper for api methods, useAPIMethod, which lets you:
    • provide default parameters and options for the API call
    • transform the response data and deal with status codes
    • abort API requests with an AbortController on reentrance (optional)
    • returns the normal useAsync stuff plus an abort command.
  • Pagination hook usePagination

In addition:

  • Tests are added for all new functionality
  • A mock API and MSW interception have been added to support testing in
    • unit-tests
    • storybook
  • Storybook for Table shows example of using APIProvider, useAPIMethod, and usePagination
Edited by John Sparger

Merge request reports