nestjs-convert-to-curl

0.0.23 • Public • Published

Covert Axios error to curl

$ npm i nestjs-convert-to-curl

Usage

// main.ts
// if your prefer to use in a global application

import { LogAxiosErrorInterceptor } from 'nestjs-convert-to-curl';

async function bootstrap() {
   .....
   app.useGlobalInterceptors(new LogAxiosErrorInterceptor());
}
curl --location -g --request POST 'http://url' --header 'Accept: application/json, text/plain, */*' --header 'Content-Type: application/json' --header 'User-Agent: axios/0.26.0' --header 'Content-Length: 13'  --data-raw '{"foo":"bar"}'

// service.ts
// If you prefer to use in a service.


import { AxiosConverter } from 'nestjs-convert-to-curl';

try {
  return await Axios.post('https://url', {
    foo: 'bar',
  });
} catch (error) {
  console.log(AxiosConverter.getCurl(error));
}
curl --location -g --request POST 'http://url' --header 'Accept: application/json, text/plain, */*' --header 'Content-Type: application/json' --header 'User-Agent: axios/0.26.0' --header 'Content-Length: 13'  --data-raw '{"foo":"bar"}'

The following is a list of all the people that have contributed to nestjs-convert-to-curl. Thanks for your contributions!

mikemajesty

License

It is available under the MIT license. License

Readme

Keywords

none

Package Sidebar

Install

npm i nestjs-convert-to-curl

Weekly Downloads

53

Version

0.0.23

License

MIT

Unpacked Size

15.9 kB

Total Files

14

Last publish

Collaborators

  • mikemajesty