onRequest method

  1. @override
void onRequest(
  1. RequestOptions options,
  2. RequestInterceptorHandler handler
)

Called when the request is about to be sent.

Implementation

@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
  try {
    debugPrint("<-- ${options.method.toUpperCase()}");

    debugPrint("Headers:");
    options.headers.forEach((k, v) => debugPrint('$k: $v'));

    debugPrint("queryParameters:");
    options.queryParameters.forEach((k, v) => debugPrint('$k: $v'));

    if (options.data != null) {
      debugPrint("Body: ${options.data}");
    }
    debugPrint("END ${options.method.toUpperCase()} -->\n");
  } catch (e) {
    debugPrint(e.toString());
  }
  super.onRequest(options, handler);
}