axios-logger
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "axios-logger", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Beautify Axios Logging Messages", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
# axios-logger | ||
> Beautify Axios Logging Messages. | ||
@@ -7,4 +8,8 @@ | ||
Basically This package is working as [Axios's interceptors](https://github.com/axios/axios#interceptors). | ||
![sample](https://user-images.githubusercontent.com/10627668/41816761-1700b662-77c8-11e8-80d4-7d223169364a.png) | ||
# Install | ||
## Install | ||
``` | ||
@@ -14,6 +19,8 @@ $ npm install axios-logger --save-dev | ||
# How to use | ||
You can use logger with `axios` interceptor. | ||
## How to use | ||
#### Request | ||
You can use various loggers through the `axios`'s interceptor API. | ||
### Logging Request | ||
```javascript | ||
@@ -27,11 +34,13 @@ import axios from 'axios'; | ||
If you want to use your custom interceptor, you can mixin with logger like this. | ||
If you want to use your own interceptor, you can compose(mixin) with `requestLogger`. | ||
```javascript | ||
instance.interceptors.request.use((config) => { | ||
// write down your request intercept. | ||
AxiosLogger.requestLogger(config); | ||
return AxiosLogger.requestLogger(config); | ||
}); | ||
``` | ||
#### Response | ||
### Logging Response | ||
```javascript | ||
@@ -45,12 +54,15 @@ import axios from 'axios'; | ||
If you want to use your custom interceptor, you can mixin with logger like this. | ||
Also if you want to use your own interceptor, you can compose(mixin) with `responseLogger`. | ||
```javascript | ||
instance.interceptors.response.use((response) => { | ||
// write down your response intercept. | ||
AxiosLogger.responseLogger(response); | ||
return AxiosLogger.responseLogger(response); | ||
}); | ||
``` | ||
#### Error | ||
You can errorLogger that pass second argument. | ||
### Error | ||
You can inject `errorLogger` right after `requestLogger` or `responseLogger`. | ||
```javascript | ||
@@ -65,11 +77,13 @@ import axios from 'axios'; | ||
If you want to use your custom interceptor, you can mixin with logger like this. | ||
Also if you want to use your own interceptor, you can compose(mixin) with `errorLogger`. | ||
```javascript | ||
instance.interceptors.response.use(AxiosLogger.requestLogger, (err) =>{ | ||
// write down your error intercept. | ||
AxiosLogger.errorLogger(err); | ||
return AxiosLogger.errorLogger(err); | ||
}); | ||
``` | ||
# CONTRIBUTE | ||
I always welcome Feedback and Pall Request :) | ||
## CONTRIBUTE | ||
I always welcome Feedback and Pull Request :) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38460
84