Gathering detailed insights and metrics for @vdtn359/format-axios-error
Gathering detailed insights and metrics for @vdtn359/format-axios-error
Gathering detailed insights and metrics for @vdtn359/format-axios-error
Gathering detailed insights and metrics for @vdtn359/format-axios-error
npm install @vdtn359/format-axios-error
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
4 Stars
19 Commits
1 Forks
2 Watching
1 Branches
2 Contributors
Updated on 09 Jul 2024
TypeScript (86.66%)
JavaScript (13.34%)
Cumulative downloads
Total Downloads
Last day
-28.6%
5
Compared to previous day
Last week
-43.2%
42
Compared to previous week
Last month
14%
253
Compared to previous month
Last year
0%
1,646
Compared to previous year
This is a small library that provides a function to format an axios error object for logging purposes. It strips any unnecessary information from the error object, making it more readable and easy to understand when reviewing logs.
Can be used with logform and winston.
Yarn
1$ yarn add -E @redtea/format-axios-error
NPM
1$ npm install -E @redtea/format-axios-error
More usage examples can be found in examples
directory.
1const axios = require('axios'); 2const {format} = require('@redtea/format-axios-error'); 3 4axios 5 .get('https://google.com/give-404') 6 .catch(error => { 7 console.log( 8 JSON.stringify(format(error), null, 2) 9 ) 10 });
will print
{
"name": "Error",
"isAxiosError": true,
"config": {
"url": "https://google.com/give-404",
"method": "get",
"headers": [headers],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1
},
"response": {
"data": [data],
"status": 404,
"statusText": "Not Found",
"headers": [headers]
}
}
In the example, response data and headers are omitted. Run the code snipped locally to see full log output.
1const winston = require('winston'); 2const axios = require('axios'); 3const {axiosError} = require('@redtea/format-axios-error/logform'); 4const {combine, json} = winston.format; 5 6const logger = winston.createLogger({ 7 level: 'info', 8 format: combine( 9 axiosError(), 10 json({ space: 2 }) 11 ), 12 transports: [ 13 new winston.transports.Console(), 14 ], 15}); 16 17axios 18 .get('https://google.com/give-404') 19 .catch(error => logger.error(error))
will print
{
"config": {
"url": "https://google.com/give-404",
"method": "get",
"headers": [headers],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1
},
"isAxiosError": true,
"level": "error",
"response": {
"status": 404,
"data": [data],
"headers": [headers],
"statusText": "Not Found"
},
"message": "Request failed with status code 404"
}
1<!DOCTYPE html> 2<html lang="en"> 3<head> 4 <meta charset="UTF-8"> 5 <title>format-axios-error browser example</title> 6 <script src="https://unpkg.com/axios" type="application/javascript"></script> 7 <script src="https://unpkg.com/@redtea/format-axios-error" type="application/javascript"></script> 8</head> 9<body> 10<script> 11 axios 12 .get('https://www.googleapis.com/give-404') 13 .catch(error => { 14 console.log( 15 JSON.stringify( 16 AxiosErrorFormat.format(error), 17 null, 18 2 19 ) 20 ) 21 }) 22</script> 23</body> 24</html>
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/18 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
43 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More