File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change
1
+ import 'dart:convert' as convert;
2
+ import 'package:http/http.dart' as http;
3
+
4
+ main (List <String > arguments) async {
5
+ // This example uses the Google Books API to search for books about http.
6
+ // https://developers.google.com/books/docs/overview
7
+ var url = "https://www.googleapis.com/books/v1/volumes?q={http}" ;
8
+
9
+ // Await the http get response, then decode the json-formatted responce.
10
+ var response = await http.get (url);
11
+ if (response.statusCode == 200 ) {
12
+ var jsonResponse = convert.jsonDecode (response.body);
13
+ var itemCount = jsonResponse['totalItems' ];
14
+ print ("Number of books about http: $itemCount ." );
15
+ } else {
16
+ print ("Request failed with status: ${response .statusCode }." );
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments