Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-logger

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-logger

Beautify Axios Logging Messages

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
72K
decreased by-16.8%
Maintainers
1
Weekly downloads
 
Created
Source

axios-logger

Beautify Axios Logging Messages.

When you send a request in nodejs, you need to show the log to the console. This library display the necessary information while communicating with the server.

sample

Install

$ npm install axios-logger --save-dev

How to use

You can use logger with axios interceptor.

Request
import axios from 'axios';
import AxiosLogger from 'axios-logger';

const instance = axios.create();
instance.interceptors.request.use(AxiosLogger.requestLogger);

If you want to use your custom interceptor, you can mixin with logger like this.

instance.interceptors.request.use((config) => {
    // write down your request intercept.
    AxiosLogger.requestLogger(config);
});
Response
import axios from 'axios';
import AxiosLogger from 'axios-logger';

const instance = axios.create();
instance.interceptors.request.use(AxiosLogger.responseLogger);

If you want to use your custom interceptor, you can mixin with logger like this.

instance.interceptors.response.use((response) => {
    // write down your response intercept.
    AxiosLogger.responseLogger(response);
});
Error

You can errorLogger that pass second argument.

import axios from 'axios';
import AxiosLogger from 'axios-logger';

const instance = axios.create();
instance.interceptors.request.use(AxiosLogger.requestLogger, AxiosLogger.errorLogger);
instance.interceptors.response.use(AxiosLogger.responseLogger, AxiosLogger.errorLogger);

If you want to use your custom interceptor, you can mixin with logger like this.

instance.interceptors.response.use(AxiosLogger.requestLogger, (err) =>{
    // write down your error intercept.
    AxiosLogger.errorLogger(err);
});

CONTRIBUTE

I always welcome Feedback and Pall Request :)

Keywords

FAQs

Package last updated on 24 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc