onRequest method
The callback will be executed before the request is initiated.
If you want to continue the request, call handler.next
.
If you want to complete the request with some custom data,
you can resolve a Response
object with handler.resolve
.
If you want to complete the request with an error message,
you can reject a DioError
object with handler.reject
.
Implementation
@override
onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
AppConfig.printLog('请求url: ${options.path}');
AppConfig.printLog('请求头: ' + options.headers.toString());
if (options.data != null) {
AppConfig.printLog('请求参数: ' + options.data.toString());
}
return super.onRequest(options, handler);
}