onRequest method
Called when the request is about to be sent.
Implementation
@override
Future<void> onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
try {
options.headers['Authorization'] = 'Bearer ${await _provider.token()}';
} catch (e) {
return handler.reject(DioException(requestOptions: options, error: e));
}
if (_mutating.contains(options.method.toUpperCase()) &&
!options.headers.containsKey('Idempotency-Key')) {
options.headers['Idempotency-Key'] = _uuidV4();
}
handler.next(options);
}