1.2.4 • Published 11 months ago

@sunrisecn/axios-abort v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

axios-abort

The axios-abort library is for axios cancel request.

Installation:

Using npm/yarn/pnpm:

npm install @sunrisecn/axios-abort --save

yarn/pnpm add @sunrisecn/axios-abort

Usage:

Starting from v0.22.0 Axios supports AbortController to cancel requests.

import axios from 'axios'
import abort from 'axios-abort'

const axios = axios.create(config)

axios.interceptors.request.use(
	config => {
		config.signal = abort.add({ url: config.url, method: config.method })
		abort.judge({ url: config.url, method: config.method })
		return config
	},
	error => Promise.reject(error)
)

axios.interceptors.response.use(
	response => {
		abort.remove({ url: response.config.url, method: response.config.method })
		return response
	},
	error => Promise.reject(error)
)

API

- add  
	- add AbortSignal to every request 
- judge
	- judge whether the cancellation conditions are met
- remove
	- remove url after success or failure
- removeAll
	- removeAll url 
1.2.0

11 months ago

1.2.4

11 months ago

1.2.3

11 months ago

1.2.2

11 months ago

1.2.1

11 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago