Velar/Frontend/monarch/lib/fetch_service.dart
2025-07-31 13:38:35 +05:30

19 lines
532 B
Dart

// ignore_for_file: avoid_print
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'enviroment.dart';
Future<List<Map<String, dynamic>>> fetchRecentTransactions() async {
final response = await http.get(
Uri.parse('${Environment.baseUrl}/api/transactions/recent'),
);
if (response.statusCode == 200) {
final List<dynamic> data = jsonDecode(response.body)['data'];
return List<Map<String, dynamic>>.from(data);
} else {
print('Failed to load recent transactions');
return [];
}
}