sendRequest method
Implementation
Future<Map<String, dynamic>> sendRequest({required String token, required String endpoint, required Object body}) async {
try {
var uri = Uri.parse(_URL_GRAPH + endpoint);
var response = await http.post(uri, headers: {
'Authorization': 'Bearer $token'
}, body: body);
var data = json.decode(response.body);
if (data == null || data['error'] != null || response.statusCode != 200 || _isStatusCodeSuccess(data)) {
print(data);
return Future.value({});
}
return Future.value(data);
} catch (exception) {
return Future.error(exception);
}
}