shouldAttemptRetryOnResponse method

  1. @override
Future<bool> shouldAttemptRetryOnResponse(
  1. BaseResponse response
)
override

Defines whether the request should be retried after the request has received response from the server.

Implementation

@override
Future<bool> shouldAttemptRetryOnResponse(BaseResponse response) async {
  try {
    //Auth token expired
    if (response.statusCode == 401) {
      if (_isRefreshing) {
        await _completer.future;
        return true;
      }

      final url = response.request?.url;
      return refreshToken(url?.toString());
    }
  } on Exception catch (_) {}
  return false;
}