fix(apps): improve ApiInterceptor retry and error handling
This commit is contained in:
@@ -19,6 +19,7 @@ class ApiClient {
|
||||
_dio.interceptors.add(
|
||||
ApiInterceptor(
|
||||
tokenStorage: _tokenStorage,
|
||||
dio: _dio,
|
||||
onTokenRefresh: _handleTokenRefresh,
|
||||
),
|
||||
);
|
||||
@@ -40,7 +41,7 @@ class ApiClient {
|
||||
Future<Response<T>> get<T>(String path, {Options? options}) async {
|
||||
try {
|
||||
return await _dio.get<T>(path, options: options);
|
||||
} catch (e) {
|
||||
} on DioException catch (e) {
|
||||
throw ApiException.fromDioError(e);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +53,7 @@ class ApiClient {
|
||||
}) async {
|
||||
try {
|
||||
return await _dio.post<T>(path, data: data, options: options);
|
||||
} catch (e) {
|
||||
} on DioException catch (e) {
|
||||
throw ApiException.fromDioError(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user