handleResponse<R> method

dynamic handleResponse<R>({
  1. R onSuccess()?,
})

Implementation

handleResponse<R>({R Function()? onSuccess}) {
  if (isSuccess()) {
    if (onSuccess != null) {
      return onSuccess();
    }
    return jsonDecode(body) as Map<String, dynamic>;
  } else if (isNotFound()) {
    throw NotFoundException();
  } else {
    throw ServerErrorException();
  }
}