get function

Future<Response> get(
  1. Uri url, {
  2. Map<String, String>? headers,
})

Sends an HTTP GET request with the given headers to the given URL.

A HttpStatusException will be thrown if any non-200 HTTP status code is returned from the request.

Implementation

Future<Response> get(Uri url, {Map<String, String>? headers}) async {
  final response = await http.get(url, headers: headers);
  if (response.statusCode != 200) throw HttpStatusException(response);
  return response;
}