axios-logger
Advanced tools
Comparing version
{ | ||
"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). | ||
 | ||
# 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
38460
33.09%84
20%