Axios and Error handling - MukeshKumar101/IPL_Auction GitHub Wiki
PROBLEM STATEMENT
To write a wrapper for axios and error handling component for handling errors.
JOBS TO BE DONE
* Create a wrapper for "axios".
* Create a wrapper for "error handling" and add interceptors for handling errors from the response of the api.
IMPLEMENTATION PLAN
1. create a wrapper for axios
* The axios file is located at app level and the file is named as "appAxios.js".
* axios wrapper is named as ProtectedAxios.
* Axios is a third party library, so install axios in our react application
(npm install axios --save).
* The axios have the following functionalities
1.1. get
1.2. post
1.3. delete
2. create a wrapper for error handling
* The error handling file is located at app level and the file is named as "errorBoundary.container.js".
* Errorboundary wrapper is named as ErrorBoundary.
* error.boundary.js uses the following lifecycles
2.1 "componentDidCatch(error, info)"
2.2 static method "getDerivedStateFromError(error)".
* const ErrorBoundary has two arguments "wrappedComponent" and "axios".
* ErrorBoundary returns a class.
* add interceptors to handle errors in componentDidMount().
* Show user end messages.
* Error messages are dialogues(alert dialogue boxes), should appear with a OK button.