1.0.7 • Published 3 months ago
nestjs-convert-to-curl v1.0.7
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(
"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"]));
}
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!
License
It is available under the MIT license. License
1.0.1
3 months ago
1.0.7
3 months ago
1.0.6
3 months ago
1.0.5
3 months ago
1.0.4
3 months ago
1.0.3
3 months ago
1.0.0
8 months ago
0.0.23
1 year ago
0.0.22
2 years ago
0.0.20
2 years ago
0.0.21
2 years ago
0.0.16
2 years ago
0.0.17
2 years ago
0.0.18
2 years ago
0.0.11
3 years ago
0.0.12
3 years ago
0.0.13
3 years ago
0.0.14
3 years ago
0.0.15
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.7
3 years ago
0.0.6
3 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago