post function
Implementation
Future<http.Response?> post(String baseAddress, String endpoint,
{Map<String, dynamic>? body}) async {
var response;
try {
var uri;
baseAddress = baseAddress.replaceFirst("https://", "");
uri = Uri.https(baseAddress, '$API_VERSION$endpoint');
response = await http.post(
uri,
body: json.encode(body),
headers: {
HttpHeaders.acceptHeader: '*/*',
HttpHeaders.contentTypeHeader: 'application/json',
},
);
return returnResponseOrThrowException(response);
} on IOException {
throw NetworkException();
} catch (e) {
print(e);
return response;
}
}