postJsonAPI method
Implementation
Future<BaseResponse> postJsonAPI(String url, data, body, {bool hasHeader = true, int timeout = 20}) async {
final baseResponse = BaseResponse();
try {
final headers = {
'Content-Type': 'application/json; charset=utf-8'
};
headers.addAll(await _getHeader(hasAuthen: hasHeader));
final response = await http.post(Uri.parse(baseUrl + url),
headers: headers, body: jsonEncode(body)).timeout(Duration(seconds: timeout));
baseResponse.fromJson(jsonDecode(response.body), data);
} catch (e) {
return _responseError(baseResponse, e);
}
return baseResponse;
}