get static method

Future<String> get(
  1. Uri uri
)

Implementation

static Future<String> get(Uri uri) async {
  final client = HttpClient();
  try {
    const timeout = Duration(seconds: 15);
    final req = await client.getUrl(uri);
    final res = await req.close().timeout(timeout);
    if (res.statusCode != HttpStatus.ok) {
      throw Exception("request $uri error , status ${res.statusCode}");
    }
    final body = await res.transform(utf8.decoder).join().timeout(timeout);
    return body;
  } finally {
    client.close();
  }
}