upvote method

Future<void> upvote(
  1. String requestId
)

Implementation

Future<void> upvote(String requestId) async {
  final userId = await userService.getUserId();

  final response = await http.post(
    Uri.parse('${apiUrl}votes'),
    headers: {
      'api-key': apiKey,
      'user-id': userId,
      "Content-Type": "application/json",
      "Accept": "application/json",
    },
    body: json.encode({
      'requestId': requestId,
      'userId': userId,
    }),
  );

  if (response.statusCode == 201) {
    return;
  } else {
    throw Exception('Failed to upvote');
  }
}