0.0.9 • Published 2 years ago

axios2curl v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Axios2curl

npm.io npm.io npm.io npm.io

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');
  });
0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago