getJSON<S, T> method

Future<T> getJSON<S, T>(
  1. String path,
  2. {int? statusCode,
  3. void fail(
    1. Response response
    )?,
  4. Map<String, String>? headers,
  5. Map<String, String>? params,
  6. JSONConverter<S, T>? convert,
  7. String? preview}
)

Handles Get Requests that respond with JSON path can either be a path like '/repos' or a full url. statusCode is the expected status code. If it is null, it is ignored. If the status code that the response returns is not the status code you provide then the fail function will be called with the HTTP Response. If you don't throw an error or break out somehow, it will go into some error checking that throws exceptions when it finds a 404 or 401. If it doesn't find a general HTTP Status Code for errors, it throws an Unknown Error. headers are HTTP Headers. If it doesn't exist, the 'Accept' and 'Authorization' headers are added. params are query string parameters. convert is a simple function that is passed this GitHub instance and a JSON object. The future will pass the object returned from this function to the then method. The default convert function returns the input object.

Implementation

Future<T> getJSON<S, T>(
  String path, {
  int? statusCode,
  void Function(http.Response response)? fail,
  Map<String, String>? headers,
  Map<String, String>? params,
  JSONConverter<S, T>? convert,
  String? preview,
}) =>
    requestJson(
      'GET',
      path,
      statusCode: statusCode,
      fail: fail,
      headers: headers,
      params: params,
      convert: convert,
      preview: preview,
    );