post<T> static method
Implementation
static Future<T> post<T>(String url, dynamic body,
{Function(Map<String, dynamic>)? mapper}) async {
try {
final response = await _client.post(Uri.parse(apiUrl + url),
headers: headers, body: body != null ? jsonEncode(body) : null);
validateResponse(response);
final jsonResponse = IApillonResponse.fromJson(jsonDecode(response.body));
if (mapper != null) {
return mapper(jsonResponse.data);
}
return jsonResponse.data;
} on SocketException {
throw ApillonNetworkError('No Internet connection');
} on HttpException catch (e) {
ApillonLogger.log(e.message, LogLevel.ERROR);
throw ApillonRequestError(e.message);
} on FormatException catch (e) {
ApillonLogger.log(e.message, LogLevel.ERROR);
throw ApillonRequestError(e.message);
}
}