Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-middleware

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-middleware

Simple axios HTTP middleware service

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.6K
decreased by-14.72%
Maintainers
1
Weekly downloads
 
Created
Source

axios-middleware

Build Status npm version

Simple axios HTTP middleware service.

Explore the documentation.

Installation

npm install --save axios-middleware

How to use

A simple example using the simplified middleware syntax.

import axios from 'axios';
import { HttpMiddlewareService } from 'axios-middleware';

// Create a new service instance
const service = new HttpMiddlewareService(axios);

// Then register your middleware instances.
service.register({
    onRequest(config) {
        // handle the request config
        return config;
    },
    onSync(promise) {
        // handle the promsie
        return promise;
    },
    onResponse(response) {
        // handle the response
        return response;
    }
});

// We're good to go!
export default service;

A common use-case would be to expose an instance of the service which consumes an axios instance configured for an API. It's then possible to register middlewares for this API at different stages of the initialization process of an application.

Keywords

FAQs

Package last updated on 26 Jun 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc