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(
    dio.RequestOptions options, dio.RequestInterceptorHandler handler) {
  options.headers = options.headers
    ..addAll({
      "Authorization": MxBaseUserInfo.instance.getToken().isTextEmpty
          ? null
          : 'Bearer ${MxBaseUserInfo.instance.getToken().mxText}',
    });
  'ApiDioInterceptor request:${options.method},${options.uri.path},${options.queryParameters},${options.data}'
      .logMx();
  super.onRequest(options, handler);
}