getJSON method

Future getJSON(
  1. String path
)

Implementation

Future<dynamic> getJSON(String path) async {
  var client = createClient();
  try {
    var response = await client
        .get(getURI(path), headers: {"User-Agent": applicationName});
    var json = jsonDecode(response.body);

    if (response.statusCode == 200) {
      return json;
    } else {
      var error = APIError.fromJson(json);
      throw error.toException();
    }
  } catch (e) {
    rethrow;
  } finally {
    client.close();
  }
}