request method
Perform the specified http request and return the response data. @param {string} url The server URL that will be used for the request. @param {object} data The data to be sent as the request body. @returns {Promise
Implementation
Future<Map<String, dynamic>> request(String url, dynamic data) async {
var res = await defaultFetch(
endpoint: url,
method: FetchMethod.post,
defaultHost: host,
baseHeaders: {'Content-Type': 'application/json;charset=utf-8'},
cbor: false,
body: jsonEncode(data),
);
var response = FetchResponse.fromMap(res);
if (response.ok) {
return jsonDecode(response.body);
} else {
throw TransactionError(
response.statusText,
response.statusCode,
detail: response.body.isNotEmpty
? jsonDecode(response.body)
: response.body,
);
}
}