refactor(llc): use dio.fetch instead of dio.request
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -266,4 +266,17 @@ class StreamHttpClient {
|
||||
throw _parseError(error);
|
||||
}
|
||||
}
|
||||
|
||||
/// Handy method to make http requests from [RequestOptions]
|
||||
/// with error parsing.
|
||||
Future<Response<T>> fetch<T>(
|
||||
RequestOptions requestOptions,
|
||||
) async {
|
||||
try {
|
||||
final response = await httpClient.fetch<T>(requestOptions);
|
||||
return response;
|
||||
} on DioError catch (error) {
|
||||
throw _parseError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user