axios-singleton
TypeScript icon, indicating that this package has built-in type declarations

1.0.2-0 • Public • Published

Axios Singleton Instance

Axios Singleton Instance for Node and Browserify projects

Quick start

import axios from 'axios-singleton'
 
const axiosInstance: any = axios
const result = await axiosInstance.get('https://api.github.com/users/Quynh-Nguyen')
 
...

If you want to customize headers

import axios from 'axios-singleton'
 
const axiosInstance: any = axios
axiosInstance.setConfigure({
  baseURL: 'https://api.github.com',
  headers: {
    common: {
      'Content-Type': 'application/json'
    }
  }
})
 
const result = await axiosInstance.get('/users/Quynh-Nguyen')
 
...

If you want to set Bearer token to headers

import axios from 'axios-singleton'
 
const axiosInstance: any = axios
axiosInstance.setHeaderToken('YOUR_TOKEN')
 
...

Readme

Keywords

Package Sidebar

Install

npm i axios-singleton

Weekly Downloads

2

Version

1.0.2-0

License

MIT

Unpacked Size

21.3 kB

Total Files

20

Last publish

Collaborators

  • likeguitarz