Prevent requests if the same request was launched, and it was not completed.
npm install axios-repeat-preventionPrevent requests if the same request was launched, and it was not completed.
``sh`
npm install --save axios-repeat-prevention
Create axios-repeat-prevention instance:
`js`
const preserveAdapter = new AxiosRepeatPreserve({
methods: ['GET'],
});
Create axios instance passing the created adapter:
`js`
const api = axios.create({
adapter: preserveAdapter.adapter
})
Just pass adapter as second argument. As an example using axios-cache-adapter:
`js``
import { setupCache } from 'axios-cache-adapter';
const cache = setupCache();
const api = axios.create({
adapter: config => preserveAdapter.adapter(config, cache.adapter)
})