Axios-Sugar

A wrapper for axios

quick start →

Axios-Like

Its usage is similar to Axios that easy to use.

Out of the box

All features can be used after simple configuration。

Custom

Through callback to ensure a certain degree of customization function.

# Axios-Like Usage

import AxiosSugar from 'axios-sugar';

AxiosSugar.get('/path/to/sevice', {
  params: {
    /**/
  }
}, {
  retry: {
    enable: true
  }
}).then(res => {
  console.log(res.data);
}).catch(err => {
  console.log(err.reason.message); // all errors are put in reason property
});

TIP

Similar points:

  1. AxiosSugar and axios
  2. AxiosSugar.create and axios.create
  3. AxiosSugar.defaults and axios.defaults
  4. AxiosSugar.isCancel and axios.isCancel
  5. A series of methods to send a request, such as request, get, post, delete
  6. AxiosSugar.interceptors

WARNING

They are not completely equivalent, just similar in usage.

# Features

  • Axios-Like Methods
  • Cancel Repeated Requests
  • Retry
  • Response Storage
  • Broken Network Retransmission
  • Handlers for Http-Status-Code Responses
  • Cancel All Requests Matched By Filter

TIP

More informations about features in config