https://github.com/mikemajesty/nestjs-convert-to-curl
Covert Axios error to curl
https://github.com/mikemajesty/nestjs-convert-to-curl
axios axios-curl axios-node convert-curl convert-error-curl
Last synced: about 1 month ago
JSON representation
Covert Axios error to curl
- Host: GitHub
- URL: https://github.com/mikemajesty/nestjs-convert-to-curl
- Owner: mikemajesty
- Created: 2022-01-15T18:57:25.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-05T00:26:18.000Z (3 months ago)
- Last Synced: 2025-04-24T02:12:39.095Z (about 1 month ago)
- Topics: axios, axios-curl, axios-node, convert-curl, convert-error-curl
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/nestjs-convert-to-curl
- Size: 349 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Covert Axios error to curl
```bash
$ npm i nestjs-convert-to-curl
```## Usage
```ts
// main.ts
// if your prefer to use in a global applicationimport { LogAxiosErrorInterceptor } from 'nestjs-convert-to-curl';
async function bootstrap() {
.....
app.useGlobalInterceptors(new LogAxiosErrorInterceptor());
}```
```bash
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"}'
```---
```ts
// service.ts
// If you prefer to use in a service.import { AxiosConverter } from "nestjs-convert-to-curl";
try {
return await Axios.post(
"http://www.mymockservice.com",
{
foo: "bar",
password: "123mudar",
employee: { name: "Mike", cpf: "41288055800" },
},
{ headers: { Authorization: "Bearer token" } }
);
} catch (error) {
console.log(AxiosConverter.getCurl(error, ["password", "cpf"]));
}
``````bash
curl --location -g --request POST 'http://www.mymockservice.com' --header 'Accept: application/json, text/plain, */*' --header 'Content-Type: application/json' --header 'Authorization: Bearer token' --header 'User-Agent: axios/1.6.7' --header 'Content-Length: 82' --header 'Accept-Encoding: gzip, compress, deflate, br' --data-raw '{"foo":"bar","password":"******","employee":{"name":"Mike","cpf":"******"}}'
```---
The following is a list of all the people that have contributed to nestjs-convert-to-curl. Thanks for your contributions!
[
](https://github.com/mikemajesty)
## License
It is available under the MIT license.
[License](https://opensource.org/licenses/mit-license.php)