This is an axios extension that makes it easier for developers to call the API through the application
- Support standards request: 
GET,POST,PATCH,DELETE,PUT. - Allow customize Axios Instance and Error Handling function.
 - TypeScript Compatibility.
 - Allow extend and modify API wrapper client by implement interfaces and extends base interceptor.
 
Npm:
npm install @devboostsolution/api-clientYarn:
yarn install @devboostsolution/api-client/**
 * Step:
 * 1. Init axios instance
 * 2. Define errorHandle function
 * 3. Init axios interceptor
 * 4. Init axios api client
 */
const axiosInstance = axios.create({
  baseURL: process.env.BASE_URL,
  timeout: 1000,
  headers: {
    'Content-Type': 'application/json;charset=utf-8',
  },
});
onst errorHandler = (error: any) => {
  if (error.response) {
    console.log(`ErrorHandler is called`);
  }
  if (error.response.data) {
    return error.response.data;
  }
  return Promise.reject(error);
};
// Mode: development, production, test
const axiosInterceptor = new AxiosInterceptor(
  axiosInstance,
  errorHandler,
  'development', 
);
const apiClient = new AxiosApiClient(axiosInterceptor);
const response = await apiClient.get({ url: '/api/category' });Clone the repository
make install
npm testDistributed under the MOT license. See LICENSE for more information.
https://github.com/DevBoostSolutions/api-client
- 
Fork it (https://github.com/DevBoostSolutions/api-client/fork)
 - 
Create your feature branch (
git checkout -b feature/fooBar) - 
Commit your changes (
git commit -am 'Add some fooBar') - 
Push to the branch (
git push origin feature/fooBar) - 
Create a new Pull Request