readOne<T> method

Future<T?> readOne<T>({
  1. T convert(
    1. Map d
    )?,
  2. Map<String, dynamic> pathParams = const {},
  3. FutureOr onError(
    1. Response resp
    )?,
})

Fetches json response and returns the decoded result

Implementation

Future<T?> readOne<T>(
    {T convert(Map d)?,
    Map<String, dynamic> pathParams = const {},
    FutureOr<dynamic> onError(ht.Response resp)?}) async {
  ht.Response resp = await go(pathParams: pathParams);
  if (resp.isSuccess) {
    return resp.json<T>(convert);
  }

  if (onError == null) {
    throw ErrorResponse(resp);
  }
  var err = await onError(resp);
  if (err != null) {
    throw err;
  }
  return null;
}