diff --git a/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart b/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart index 58db2fe3..759e8e79 100644 --- a/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart +++ b/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart @@ -60,30 +60,7 @@ class AuthInterceptor extends QueuedInterceptor { await _tokenManager.loadToken(refresh: true); try { final options = err.requestOptions; - final response = await _client.request( - options.path, - cancelToken: options.cancelToken, - data: options.data, - onReceiveProgress: options.onReceiveProgress, - onSendProgress: options.onSendProgress, - queryParameters: options.queryParameters, - options: Options( - method: options.method, - sendTimeout: options.sendTimeout, - receiveTimeout: options.receiveTimeout, - extra: options.extra, - headers: options.headers, - responseType: options.responseType, - contentType: options.contentType, - validateStatus: options.validateStatus, - receiveDataWhenStatusError: options.receiveDataWhenStatusError, - followRedirects: options.followRedirects, - maxRedirects: options.maxRedirects, - requestEncoder: options.requestEncoder, - responseDecoder: options.responseDecoder, - listFormat: options.listFormat, - ), - ); + final response = await _client.fetch(options); return handler.resolve(response); } on DioError catch (error) { return handler.next(error); diff --git a/packages/stream_chat/lib/src/core/http/stream_http_client.dart b/packages/stream_chat/lib/src/core/http/stream_http_client.dart index 169492a7..7052ce38 100644 --- a/packages/stream_chat/lib/src/core/http/stream_http_client.dart +++ b/packages/stream_chat/lib/src/core/http/stream_http_client.dart @@ -266,4 +266,17 @@ class StreamHttpClient { throw _parseError(error); } } + + /// Handy method to make http requests from [RequestOptions] + /// with error parsing. + Future> fetch( + RequestOptions requestOptions, + ) async { + try { + final response = await httpClient.fetch(requestOptions); + return response; + } on DioError catch (error) { + throw _parseError(error); + } + } }