{"id":16612332,"url":"https://github.com/svsool/axios-better-stacktrace","last_synced_at":"2025-05-08T21:30:03.980Z","repository":{"id":53966931,"uuid":"317647024","full_name":"svsool/axios-better-stacktrace","owner":"svsool","description":"Axios plugin that provides better stack traces for axios errors","archived":false,"fork":false,"pushed_at":"2024-07-26T18:56:14.000Z","size":208,"stargazers_count":48,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-13T01:41:46.010Z","etag":null,"topics":["axios","axios-plugin","error-handling","stacktrace"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/axios-better-stacktrace","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/svsool.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-01T19:31:49.000Z","updated_at":"2024-10-11T09:50:46.000Z","dependencies_parsed_at":"2024-10-25T18:29:53.816Z","dependency_job_id":"05efc219-c7c1-4025-bf2c-069dcc7df0eb","html_url":"https://github.com/svsool/axios-better-stacktrace","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":"0.023809523809523836","last_synced_commit":"3315c30ed68a23a4a041f522d208d395ac930254"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svsool%2Faxios-better-stacktrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svsool%2Faxios-better-stacktrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svsool%2Faxios-better-stacktrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svsool%2Faxios-better-stacktrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/svsool","download_url":"https://codeload.github.com/svsool/axios-better-stacktrace/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238044095,"owners_count":19407128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axios","axios-plugin","error-handling","stacktrace"],"created_at":"2024-10-12T01:41:43.226Z","updated_at":"2025-02-10T02:10:29.721Z","avatar_url":"https://github.com/svsool.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# axios-better-stacktrace\n\nAxios plugin that provides better stack traces for axios errors.\n\nCheck [this axios issue](https://github.com/axios/axios/issues/2387) for more details.\n\n[![npm](https://img.shields.io/npm/v/axios-better-stacktrace.svg?label=npm%20package)](https://www.npmjs.com/package/axios-better-stacktrace)\n[![npm](https://img.shields.io/npm/dt/axios-better-stacktrace.svg)](https://www.npmjs.com/package/axios-better-stacktrace)\n[![ci](https://github.com/svsool/axios-better-stacktrace/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/svsool/axios-better-stacktrace/actions/workflows/ci.yml?query=branch%3Amain)\n[![npm](https://img.shields.io/npm/l/axios-better-stacktrace.svg)](https://choosealicense.com/licenses/mit)\n\n## Installation\n\nNPM\n```bash\nnpm install axios-better-stacktrace\n```\n\nYarn\n```bash\nyarn add axios-better-stacktrace\n```\n\n### Note\n\nIt was tested with `axios 0.21.0`.\n\n## Usage\n\n```js\n// CommonJS\n// const axiosBetterStacktrace = require('axios-better-stacktrace').default;\n\n// ES6\nimport axiosBetterStacktrace from 'axios-better-stacktrace';\n\n// use it before any other interceptors\naxiosBetterStacktrace(axiosAgent);\n\n// when using promises response error will get an enhanced stack trace automatically\naxiosAgent.get('https://npmjs.com/\u003cnot-found\u003e/').catch(enhancedError =\u003e console.error(enhancedError));\n\n// or using async/await\n(async () =\u003e {\n  try {\n    await axiosAgent.get('https://npmjs.com/\u003cnot-found\u003e/');\n  } catch (enhancedError) {\n    console.error(enhancedError);\n  }\n})();\n\n// or using a response interceptor and an error callback (e.g. could be useful with a logging middleware)\naxiosAgent.interceptors.response.use(response =\u003e response, enhancedError =\u003e {\n  console.error(enhancedError);\n\n  return result;\n});\n\n// you can restore original agent behavior if needed\nconst restoreAgent = axiosBetterStacktrace(axiosAgent);\n\n// some code here...\n\nrestoreAgent \u0026\u0026 restoreAgent();\n```\n\nSee also [demo](./demo/index.ts).\n\n## Options\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| errorMsg | `String` | `Axios Better Stacktrace` | Error message to show next to the original one in the output. |\n\n## Example\n\nDefault axios error without an `axios-better-stacktrace` plugin:\n\n```\nError: Request failed with status code 404\n    at createError (./node_modules/axios/lib/core/createError.js:16:15)\n    at settle (./node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (./node_modules/axios/lib/adapters/http.js:244:11)\n    at IncomingMessage.emit (node:events:388:22)\n    at IncomingMessage.EventEmitter.emit (node:domain:470:12)\n    at endReadableNT (node:internal/streams/readable:1294:12)\n    at processTicksAndRejections (node:internal/process/task_queues:80:21)\n```\n\nEnhanced axios error with an `axios-better-stacktrace` plugin (run `yarn demo` to see):\n\n```\nError: Request failed with status code 404\n    at createError (./node_modules/axios/lib/core/createError.js:16:15)\n    at settle (./node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (./node_modules/axios/lib/adapters/http.js:244:11)\n    at IncomingMessage.emit (node:events:388:22)\n    at IncomingMessage.EventEmitter.emit (node:domain:470:12)\n    at endReadableNT (node:internal/streams/readable:1294:12)\n    at processTicksAndRejections (node:internal/process/task_queues:80:21)\nError: Axios Better Stacktrace\n    at Function.axiosBetterStacktraceMethodProxy [as get] (./src/axiosBetterStacktrace.ts:167:15)\n    at getNpmPage (./demo/index.ts:10:35) \u003c---- this is what usually useful to know for further debugging and this plugin adds 🙂\n    at ./demo/index.ts:13:9\n    at step (./demo/index.ts:33:23)\n    at Object.next (./demo/index.ts:14:53)\n    at ./demo/index.ts:8:71\n    at new Promise (\u003canonymous\u003e)\n    at __awaiter (./demo/index.ts:4:12)\n    at ./demo/index.ts:12:2\n    at Object.\u003canonymous\u003e (./demo/index.ts:16:3)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvsool%2Faxios-better-stacktrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsvsool%2Faxios-better-stacktrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvsool%2Faxios-better-stacktrace/lists"}