onRequest method

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

Called when the request is about to be sent.

Implementation

@override
Future<dynamic> onRequest(
  RequestOptions options,
  RequestInterceptorHandler handler,
) async {
  final currentToken = await token;
  final headers = currentToken != null
      ? _tokenHeader(currentToken)
      : const <String, String>{};
  options.headers.addAll(headers);
  handler.next(options);
}