get abstract method

Future<JSON> get({
  1. required String host,
  2. String? path,
  3. Map<String, String>? queryParameters,
  4. Map<String, String>? headers,
  5. bool isHttps,
  6. Duration timeout,
})

Fetches the JSON object from the HTTP endpoint using the path, queryParameters and headers for the RESTful service host.

If the response body is not a Map<String, dynamic>, the body will be wrapped in a hashmap in a field with the key "data".

The HTTP request/response properties are added to the JSON with the following keys:

  • the "_%path" is the endpoint path string;
  • the "_%status" is the response statusCode;
  • the "_%query" is a hashmap containing the request query parameters;
  • the "_%headers" is a hashmap containing the request headers;

If an error occurs the "data" field will contain the error object.

If no response is received, the "data" field contains a generic error message and the status code is -1.

Implementation

Future<JSON> get(
    {required String host,
    String? path,
    Map<String, String>? queryParameters,
    Map<String, String>? headers,
    bool isHttps,
    Duration timeout});