Socket
Book a DemoInstallSign in
Socket

@deleteagency/axios-singular

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deleteagency/axios-singular

A wrapper around axios that makes sure only one request is in progress at the same time

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
107
35.44%
Maintainers
1
Weekly downloads
 
Created
Source

Axios Singular

Live Demo

Motivation

TODO About parallel request and not guaranteed order of receiving reponses

Installation

Use the package manager npm for installation.

$ npm install @deleteagency/axios-singular

Usage

import axios from  'axios';
import AxiosSingular from  '@deleteagency/axios-singular';

const instance = new AxiosSingular(axios);

instance.get("/posts")
    .then((response) => {
        console.log(response)
    },() => {
        if (axios.isCancel(error)) {
            console.log('Request canceled' , error)
        }else{
            console.error('Actual error!' , error)
        }
    })

API

constructor(axiosInstance[, CancelToken, isCancel])

Returns AxiosSingular.

In order to use custom axios instance you have to pass CancelToken and isCancel as additional arguments. That's because custom instances don't have all base axios properties. Read this comment: https://github.com/axios/axios/issues/1330#issuecomment-362846633

axiosInstance

Required
Type: object

Default or any custom axios instance. See details here: https://github.com/axios/axios#creating-an-instance

CancelToken

Optional
Type: object

CancelToken from the base axios instance

isCancel

Optional
Type: Function

isCancel from the base axios instance

get(...) (request, delete, head, options, post, put, patch)

Returns Promise.

Corresponding axios methos is called under the hood with all arguments bypassed. Supported methods: request, get, delete, head, options, post, put, patch See https://github.com/axios/axios#request-method-aliases

cancel([reason])

Cancel current request if it is in progress

License

MIT

FAQs

Package last updated on 25 Nov 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.