postFetch static method
Implementation
static dynamic postFetch(String token, ApiEndpoint endpoint, dynamic body) async {
final String constructedUrl = apiEndpointUrl(BASE_URL, endpoint);
try {
var url = Uri.parse(constructedUrl);
var response = await http.post(url, body: jsonEncode(body), headers: getHeaders(token));
if (response.statusCode >= 400 && response.statusCode < 600) {
if (kDebugMode) {
print('Bad response from server.');
}
return null;
}
return json.decode(response.body);
} catch (err) {
if (kDebugMode) {
print(err);
}
}
}