https://github.com/beatakr/axios-har-tracker
This library was designed for gathering HAR files from requests sent using axios
https://github.com/beatakr/axios-har-tracker
axios har harfile tracker
Last synced: about 1 year ago
JSON representation
This library was designed for gathering HAR files from requests sent using axios
- Host: GitHub
- URL: https://github.com/beatakr/axios-har-tracker
- Owner: BeataKr
- Created: 2020-11-23T07:03:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-15T05:53:29.000Z (almost 2 years ago)
- Last Synced: 2025-07-07T00:08:17.044Z (about 1 year ago)
- Topics: axios, har, harfile, tracker
- Language: TypeScript
- Homepage: https://github.com/BeataKr/axios-har-tracker
- Size: 413 KB
- Stars: 10
- Watchers: 1
- Forks: 11
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README

This library was designed for gathering HAR files from requests sent using `axios`
# Credits
Inspiration and some pieces of the code comes from [maciejmaciejewski/request-har](https://github.com/maciejmaciejewski/request-har)
# Usage
In order to use this package install it
```js
npm install axios-har-tracker
```
and import it by
```js
import { AxiosHarTracker } from "axios-har-tracker";
```
and `axios` package
```js
import axios from "axios";
```
which will be passed into `AxiosHarTracker` constructor:
```js
const axiosTracker = new AxiosHarTracker(axios);
```
In order to perform an actual request use the axios.get/post/delete... call, examples:
```js
await axios.get("http://httpstat.us/200");
```
or with catching an error
```js
try {
await axios.get("http://httpstat.us/404");
} catch (error) {
console.log("An error appears after call to https://httpstat.us/404:", error);
}
```
Every single request is pushed into the object and user can get it by using
```js
const generatedObject = axiosTracker.getGeneratedHar();
```
Object can be saved into a file in any time using e.g.
```js
writeFileSync("example.har", JSON.stringify(generatedObject), "utf-8");
```