I was wondering if its possible to log the requests, response and errors using the HttpService from the HttpModule.
I used to use Interceptors from AXIOS, HttpService wraps axios but I can't seem to add any interceptors here, there doesn't seem to be a place in
HttpModule.register(...)
Then I thought that NestJS comes with its own interceptors and wondered if its possible to use NestJS interceptors.
I wouldn't want to apply the interceptor over a controller, service but apply it to the HttpService?
Any ideas, a little lost how to do this in the nestjs way.
Thanks in advance
The HttpService exposes its axios instance directly via get axiosRef(). With it, you can add an axios interceptor:
this.httpService.axiosRef.interceptors.request.use(config => console.log(config));
You can for example do that in the onModuleInit() of your AppModule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With