0.0.4 • Published 2 years ago
rilog-lib v0.0.4
Rilog lib
Simple way to logging and debugging your web apps. Rilog lib collects requests, collects the local storage state, and does some request analytics. Know, rilog-lib is adapted for axios. But you can also use it with fetch soon.
Installation and usage
Installing
yarn add rilog-lib
or
npm i rilog-lib
Usage (axios)
- Import Rilog object from lib.
import { Rilog } from 'rilog-lib'
- Init Rilog
Rilog.init({
key: 'RILOG_APP_KEY',
config: {}
})
- Set up config if you need:
config: {
headers: [] // Write the headers you want to store
localStorage: [] // Write the params from Local Storage you want to store
sensetiveRequsts: [] // Write the URL of request you want to exclude from storing
sensetiveDataRequests: [] // Write the URL of the request you want to exclude from storing request data
}
- Set up axios your axios instance and interceptors. Add pushRequest and pushResponse functions.
instance.interceptors.request.use(async function (request) { // Your axios instance
Rilog.pushRequest(request);
})
instance.interceptors.response.use(function(response) {
Rilog.pushResponse(response);
}, function(error) {
Rilog.pushResponse(error);
return Promise.reject(error);
})