postAndGetList<T> function
Make a POST request sending a json object, with an optional json list response
Implementation
Future<ApiResponse<List<T>>> postAndGetList<T>({
required String url,
required Map<String, dynamic> body,
required FromJson<T> fromJson,
GetHeaders? headers,
Duration? timeout,
}) async {
try {
var _headers = headers != null ? await headers() : _defaultHeaders;
var requestFuture =
_client.post(Uri.parse(url), headers: _headers, body: jsonEncode(body));
var response = await _makeRequest(requestFuture, timeout);
return _handleListResult('POST', url, response, fromJson);
} on Exception catch (e, stack) {
_onException('POST', url, -1, e, stack);
return ApiResponse(-1, error: e.toString());
}
}