onRequest method

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

Called when the request is about to be sent.

Implementation

@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
  if (showLogRequest) {
    String loggerText = "API-REQUEST";
    loggerText += "\nAPI PATH: ${options.baseUrl}${options.path}";
    loggerText += "\nMETHOD: ${options.method}";
    loggerText += "\nHEADER: ${options.headers}";
    if (options.data != null) {
      loggerText += "\nDATA: ${options.data}";
    }
    logger.d(loggerText);
  }
  super.onRequest(options, handler);
}