axios-repeat-prevention
v1.0.3
Published
Prevent requests if the same request was launched, and it was not completed.
Downloads
182
Readme
Axios Repeat Prevention
Prevent requests if the same request was launched, and it was not completed.
Install
npm install --save axios-repeat-prevention
Usage
Create axios-repeat-prevention
instance:
const preserveAdapter = new AxiosRepeatPreserve({
methods: ['GET'],
});
Create axios
instance passing the created adapter:
const api = axios.create({
adapter: preserveAdapter.adapter
})
With another adapter
Just pass adapter as second argument. As an example using axios-cache-adapter
:
import { setupCache } from 'axios-cache-adapter';
const cache = setupCache();
const api = axios.create({
adapter: config => preserveAdapter.adapter(config, cache.adapter)
})