get<T> method

Future<T> get<T>(
  1. String path, {
  2. Map<String, String>? headers,
  3. Map<String, dynamic>? queryParameters,
})

Sends an HTTP GET request to path and decodes the JSON response as T.

Relative paths are joined with baseUrl. Optional queryParameters are converted to string query parameters and appended to the URI.

Throws an http.ClientException if the HTTP status code is outside 200..299, or a TimeoutException if the request exceeds timeout.

final task = await client.get<Map<String, dynamic>>('/tasks/123');

Implementation

Future<T> get<T>(
  String path, {
  Map<String, String>? headers,
  Map<String, dynamic>? queryParameters,
}) async {
  final res =
      await _send('GET', path, headers: headers, queryParameters: queryParameters);
  return res as T;
}