post method
Future<T>
post({
- required TGPostRequest request,
- dynamic onSuccess(
- dynamic T
- dynamic onError(
- dynamic T
Implementation
Future<T> post(
{required TGPostRequest request, onSuccess(T)?, onError(T)?}) async {
try {
Uri uri = Uri.parse(request.getUrl());
TGLog.t("POST", uri);
TGRequestContent content =
TGRequestContent(request.body(), request.headers());
final httpRes = await _getClient(request.getUri(), "POST").post(
uri,
body: content.body,
headers: content.headers,
);
return _performCallback(httpRes, onError, onSuccess);
} catch (error) {
T t = _populateExceptionResponse(error);
onError!(t);
return t;
}
}