Implement RequestInterceptor
class or define function with following signature FutureOr<Request> RequestInterceptorFunc(Request request)
Request interceptor are called just before sending request
final chopper = ChopperClient(
interceptors: [
(request) async => request.copyWith(body: {}),
]
);
Implement ResponseInterceptor
class or define function with following signature FutureOr<Response> ResponseInterceptorFunc(Response response)
{% hint style="info" %} Called after successful or failed request {% endhint %}
final chopper = ChopperClient(
interceptors: [
(Response response) async => response.replace(body: {}),
]
);
Both the CurlInterceptor
and HttpLoggingInterceptor
use the dart logging package.
In order to see logging in console the logging package also needs to be added to your project and configured.
For example:
Logger.root.level = Level.ALL; // defaults to Level.INFO
Logger.root.onRecord.listen((record) {
print('${record.level.name}: ${record.time}: ${record.message}');
});