httpRequest method

  1. @override
Future<Map> httpRequest(
  1. Uri uri,
  2. Map<String, dynamic> request
)
override

Processes the HTTP request returning the HTTP response as a JSON Object

Implementation

@override
Future<Map<dynamic, dynamic>> httpRequest(
    Uri uri, Map<String, dynamic> request) {
  final completer = Completer<Map<String, dynamic>>();
  final reqText = json.encode(request);
  final headers = <String, String>{contentType: jsonMimeType};
  BrowserClient().post(uri, headers: headers, body: reqText).then((req) {
    final Map<String, dynamic> resp = json.decode(req.body);
    completer.complete(resp);
    return completer.future;
  }, onError: (final error) {
    completer.complete(<String, dynamic>{});
    return completer.future;
  });
  return completer.future;
}