fetchJson function

Future fetchJson(
  1. Uri url, {
  2. Map<String, String>? headers,
  3. Object? reviver(
    1. Object? key,
    2. Object? value
    )?,
})

Fetch content body as JSON data from a HTTP(S) resource identified by url.

An optional reviver function is applied when decoding json string data. See JsonCodec of the dart:convert package for more information.

Throws an ApiException if fetching fails. Also response status codes other than codes for success are thrown as exceptions.

Implementation

Future<dynamic> fetchJson(
  Uri url, {
  Map<String, String>? headers,
  Object? Function(Object? key, Object? value)? reviver,
}) =>
    headers != null
        ? HttpFetcher.simple().headers(headers).fetchJson(url)
        : HttpFetcher.simple().fetchJson(url);