Giter Site home page Giter Site logo

anthonygauthier / axios-middleware Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emileber/axios-middleware

0.0 1.0 0.0 356 KB

Simple axios middleware service

Home Page: https://emileber.github.io/axios-middleware/

License: MIT License

JavaScript 100.00%

axios-middleware's Introduction

axios-middleware

Build Status Dependency 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.

axios-middleware's People

Contributors

anthonygauthier avatar emileber avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.