shelf_client 0.0.6 copy "shelf_client: ^0.0.6" to clipboard
shelf_client: ^0.0.6 copied to clipboard

HTTP client based on shelf package.

example/example.dart

import 'dart:convert';

import 'package:shelf_client/shelf_client.dart';

Future<void> main(List<String> arguments) async {
  var client = Client();

  var response = await client.get(
    Uri(
      scheme: 'https',
      host: 'api.github.com',
      path: 'search/repositories',
      queryParameters: <String, String>{'q': 'Dart HTTP client'},
    ),
    headers: <String, String>{
      'Accept': 'application/vnd.github+json',
      'X-GitHub-Api-Version': '2022-11-28',
    },
  );

  if (response.statusCode == 200) {
    var stringBody = await response.readAsString();
    var jsonResponse = jsonDecode(stringBody) as Map<String, Object?>;
    var totalCount = jsonResponse['total_count'];
    print('Number of repositories: $totalCount.');
  } else {
    print('Request failed with status: ${response.statusCode}.');
  }

  client.close();
}
0
likes
150
points
89
downloads

Publisher

unverified uploader

Weekly Downloads

HTTP client based on shelf package.

Homepage
Repository (GitHub)
View/report issues

Topics

#client #http #shelf

Documentation

API reference

License

MIT (license)

Dependencies

shelf

More

Packages that depend on shelf_client