0.28.5 • Published 2 years ago

axios-auto v0.28.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

axios-auto

Build Status NPM Package Version NPM Package Downloads Known Vulnerabilities GitHub Views GitHub Clones License: MIT

About

Simple Axios wrapper with basic retry & tor support

axios-auto is an easy to use Axios client wrapper function that transforms your favoriate HTTP client library to fault tolerant client-side load balancer.

Installation

Node.js

# Wouldn't work without axios installed
npm install axios
npm install axios-auto

Documentation

https://ayanamitech.github.io/axios-auto

Usage

Browser

Every release of axios-auto will have new build of ./dist/browser/index.js for use in the browser. To get access to module classes use axios global variable.

WARN: We recommend hosting and controlling your own copy for security reasons

<!-- Since Browser bundle comes with axios built in, no need to add additional axios dependency -->
<script src="https://cdn.jsdelivr.net/npm/axios-auto@latest"></script>
<!-- Since Browser bundle comes with axios built in, no need to add additional axios dependency -->
<script src="https://unpkg.com/axios-auto@latest"></script>

Example

// CommonJS
const axios = require('axios-auto');

or

const Axios = require('axios');
const axios = require('axios-auto');

// Include axios instance as options
axios.get({...options, axios: Axios });

// ModuleJS (ES6 Modules)
import * as axios from 'axios-auto';

/**
  GET request
**/
axios.get('https://ifconfig.co/json').then(result => {
  // Equivalent to axios.get().then(result => console.log(result.data));
  console.log(result);
}).catch(error => {
  // Equivalent with axios.get().catch(e => console.error(e));
  console.error(error);
});

/**
  POST request
**/
axios.post('https://reqbin.com/echo/post/json', { 'id': 1, 'price': 10000 }).then(result => {
  console.log(result);
}).catch(error => {
  // Equivalent with axios.post().catch(e => console.error(e));
  console.error(error);
});

Please checkout Type Definition for required parameters and expected output.

0.28.5

2 years ago

0.28.4

2 years ago

0.28.3

2 years ago

0.28.2

2 years ago

0.28.1

2 years ago

0.28.0

2 years ago

0.27.4

2 years ago

0.27.3

2 years ago

0.27.2

2 years ago