post method

Future<Map<String, dynamic>> post(
  1. String endpoint,
  2. dynamic body, {
  3. bool auth = true,
})

Convenience POST wrapper that parses JSON and checks status.

Implementation

Future<Map<String, dynamic>> post(String endpoint, dynamic body,
    {bool auth = true}) async {
  final r = await makeRequest(
    'POST',
    Uri.parse('$apiUrl$endpoint'),
    body: json.encode(body),
    useAuth: auth,
  );

  final d = json.decode(utf8.decode(r.bodyBytes, allowMalformed: true));
  if (d['status'] != true) throw Exception(d['message']);
  return d;
}