postBytes method

Future<List<int>> postBytes(
  1. String endpoint, {
  2. required Map<String, dynamic> data,
})

Implementation

Future<List<int>> postBytes(
  String endpoint, {
  required Map<String, dynamic> data,
}) async {
  final response = await client.post(
    Uri.parse('$baseUrl$endpoint'),
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer $authToken',
    },
    body: jsonEncode(data),
  );

  if (response.statusCode == 200) {
    return response.bodyBytes;
  }

  throw Exception('Request failed: ${response.statusCode}\n${response.body}');
}