daphne_http 1.2.0 copy "daphne_http: ^1.2.0" to clipboard
daphne_http: ^1.2.0 copied to clipboard

A composable, multi-platform, Future-based API for HTTP requests.

example/main.dart

import 'dart:convert' as convert;

import 'package:daphne_http/http.dart' as http;

void main(List<String> arguments) async {
  // This example uses the Google Books API to search for books about http.
  // https://developers.google.com/books/docs/overview
  var url = Uri.https('www.googleapis.com', '/books/v1/volumes', {'q': '{http}'});

  // Await the http get response, then decode the json-formatted response.
  var response = await http.get(url);
  if (response.statusCode == 200) {
    var jsonResponse = convert.jsonDecode(
      response.body,
    ) as Map<String, dynamic>;
    var itemCount = jsonResponse['totalItems'];
    print('Number of books about http: $itemCount.');
  } else {
    print('Request failed with status: ${response.statusCode}.');
  }
}
0
likes
130
points
101
downloads

Publisher

verified publisherapollosoftware.xyz

Weekly Downloads

A composable, multi-platform, Future-based API for HTTP requests.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

async, http_parser, meta

More

Packages that depend on daphne_http