axios-cache-interceptor/docs/pages/development-mode.md
Arthur Fiorette 7293cf0c26
feat!: new bundle setup & fixed development bundles (#167)
* feat: added issue template

* fix: move dev bundles to a specific folder

* docs: some documentation changes

* docs: updated issue template

* chore!: updated build setup

* style: formatted code

* chore: allow importing any file
2022-03-11 13:46:08 -03:00

784 B

Development

TL;DR: import { setupCache } from 'axios-cache-interceptor/dev';

All debugging information is emitted into a different bundle, this way it's possible to prevent unnecessary code from being bundled into the production build.

Checkout how it helps debugging:

const Axios = require('axios');
const { setupCache } = require('axios-cache-interceptor/dev');

const axios = setupCache(Axios, {
  // Print all debug information to the console
  debug: console.log
});

const req1 = axios.get('https://jsonplaceholder.typicode.com/posts/1');
const req2 = axios.get('https://jsonplaceholder.typicode.com/posts/1');

const [res1, res2] = await Promise.all([req1, req2]);

console.log('Request 1:', res1.cached);
console.log('Request 2:', res2.cached);