🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

axios-shadow

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-shadow

wrapper for axios to code splitting

0.1.3
latest
Source
npm
Version published
Weekly downloads
4
-50%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Coverage Status

axios-shadow

A wrapper for axios to code splitting.

Installation

npm i axios-shadow

Usage

Init with a splitting axios

With dynamic imports we can split axios from the main bundle.

import axios from 'axios-shadow';

axios.getModule = () => import('axios');
// or
axios.getInstance = () => import('axios').then(({default: axios}) => {
  // you can init global axios defaults and interceptors
  axios.defaults.baseURL = 'https://api.example.com';
  // ...

  // custom instance also support
  // return axios.create();
  return axios;
});

Use a shadow instance

// axios.js
import {create} from 'axios-shadow';

const axios = create();

axios.getInstance = () => import('axios').then(m => m.default.create());

export default axios;

Use axios shadow for request

import axios from 'axios-shadow';
// or
import axios from './axios';

// all async methods are proxied
axios(url).then(response => {});
axios.get(url).then(response => {});

Compatibility Note

This lib support these browsers or devices with these methods or APIs pollyfilled.

Workflow

# develop
npm start

# build
npm run build

# test
npm test

# commit changes
npm run commit

# publish
npm publish

Keywords

axios

FAQs

Package last updated on 31 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts