iws_http 0.7.1
iws_http: ^0.7.1 copied to clipboard
Library to facilitate http requests with error handling for Rest API requests.
example/main.dart
import 'dart:convert' as convert;
import 'package:iws_http/iws_http.dart';
void main() async {
final iwsHttp =
IwsHttp.setup(authority: 'googleapis.com', basePath: 'books/v1/');
try {
var response =
await iwsHttp.get(path: 'volumes', queryParameters: {'q': '{http}'});
var jsonResponse =
convert.jsonDecode(response.body) as Map<String, dynamic>;
var itemCount = jsonResponse['totalItems'];
print('Number of books about http: $itemCount.');
} on ApiException catch (e) {
print('Request failed with status: ${e.httpCode}.');
}
}