Coder Social home page Coder Social logo

axios-har-tracker's Introduction

npm

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

Usage

In order to use this package install it

npm install axios-har-tracker

and import it by

import { AxiosHarTracker } from "axios-har-tracker";

and axios package

import axios from "axios";

which will be passed into AxiosHarTracker constructor:

const axiosTracker = new AxiosHarTracker(axios);

In order to perform an actual request use the axios.get/post/delete... call, examples:

await axios.get("http://httpstat.us/200");

or with catching an error

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

const generatedObject = axiosTracker.getGeneratedHar();

Object can be saved into a file in any time using e.g.

writeFileSync("example.har", JSON.stringify(generatedObject), "utf-8");

axios-har-tracker's People

Contributors

beatakr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

axios-har-tracker's Issues

Only captures some request headers

@BeataKr Thank you for publishing this library - it has been a huge help!

I noticed that it only captures the common request headers:

headers: this.getHeaders(config.headers['common']),

Please could you tell me if this is a deliberate design choice or just an oversight? I would be very interested in either having an option to capture all request headers, or that being the default behavior. I thought Iโ€™d best check first what the rationale for the current design was.

Does this lib catches only GET requests?

I've tried to implement the lib, however I was not able to generate any pages. It does output an empty json file:
{"log":{"version":"1.2","creator":{"name":"axios-har-tracker","version":"0.1.0"},"pages":[],"entries":[]}}

I've done everything by the instructions and I'm passing the axios object at the begging, however it fails to capture anything.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.