Giter Site home page Giter Site logo

joalisonpereira / axios2curl Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 178 KB

An axios plugin that translates requests into cURL commands

License: MIT License

Shell 3.00% JavaScript 12.60% TypeScript 84.41%
axios curl debug debuggin http javascript log logging node shell

axios2curl's Introduction

Axios2curl

An axios plugin that translates requests into cURL commands.

Install

npm install axios2curl@latest

Usage

import { axios2Curl } from 'axios2curl';
import axios from 'axios';

const api = axios.create({ baseURL: 'http://localhost:3000' });

axios2Curl(api, (curl) => console.info(curl));

Log

curl -X GET "http://localhost:3000/" -H "Accept: application/json, text/plain, */*"

Disable the logger

By default, all requests will be logged. However, you can disable this behavior on a per-request basis by setting the header ___DISABLE_CURL___ to true. Rest assured, we will remove this header before your request is processed.

import { axios2Curl, DISABLE_CURL } from 'axios2curl';
import axios from 'axios';

axios2Curl(axios, (curl) => console.info(curl));

axios
  .get(
    'http://localhost:3000',
     headers: {
      [DISABLE_CURL]: 'true'
    }
)
  .then(() => {
    console.log('Success');
  })
  .catch(() => {
    console.log('Error');
  });

axios2curl's People

Contributors

joalisonpereira avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.