API communication ICSHWI-10103
This merge request adds:
- Hooks and contexts for generating/getting an OpenAPI client (
useCreateAPIClient
andAPIProvider
) - 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 anabort
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 usingAPIProvider
,useAPIMethod
, andusePagination
- You should be able to see the Storybook here: http://ccce.pages.esss.lu.se/dev/ce-ui-common
Edited by John Sparger