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) {
  final curlCommand =
      (options.data is! FormData) ? generateCurlCommand(options) : "NaN";
  Logger.d(
    'Request : ${options.uri}\n'
    '——————————————————————————————————————————————————————————————————————\n'
    'Header: ${options.headers}\n'
    '——————————————————————————————————————————————————————————————————————\n'
    'Request Body: ${(options.data is FormData) ? "Sending form data request" : jsonEncode(options.data)}\n'
    '——————————————————————————————————————————————————————————————————————\n'
    'cURL: $curlCommand\n',
  );
  return handler.next(options);
}