A console logger for Axios HTTP client.
npm install @freewall/axios-console-logger
import { AxiosConsoleLogger } from '@freewall/axios-console-logger';
const logger = new AxiosConsoleLogger();
axios.interceptors.request.use((request) => logger.request(request));
axios.interceptors.response.use(
(response) => logger.response(response),
(error) => logger.error(error),
);
// default values:
new AxiosConsoleLogger({
colors: {
get: {
request: '#54b7d3',
response: '#408ba1',
},
post: {
request: '#96c750',
response: '#6f943b',
},
},
multiline: false,
responseSize: true,
responseTime: true,
requestKeys: ['params', 'data'],
responseKeys: ['data'],
});