fetchData<T, M extends Decodable<T> > method
Future<Result<T, NetworkException> >
fetchData<T, M extends Decodable<T> >(
- TargetType targetType,
- M data
Implementation
Future<Result<T, NetworkException>> fetchData<T, M extends Decodable<T>>(TargetType targetType, M data,) async {
try {
try {
var response = await _dio.fetch(await createRequestOptions(targetType));
data.statusCode = response.statusCode;
return Success(data.fromJson(response.data));
} catch (error) {
return Failure(customErrorHandler(ParseException()));
}
} on DioException catch (_) {
return Failure(customErrorHandler(NoConnection()));
}
}