Velar/Frontend/monarch/lib/fetch_service.dart

20 lines
532 B
Dart
Raw Normal View History

2025-06-30 03:20:49 -07:00
// ignore_for_file: avoid_print
import 'package:http/http.dart' as http;
import 'dart:convert';
2025-07-31 01:08:35 -07:00
import 'enviroment.dart';
2025-06-30 03:20:49 -07:00
Future<List<Map<String, dynamic>>> fetchRecentTransactions() async {
final response = await http.get(
2025-07-31 01:08:35 -07:00
Uri.parse('${Environment.baseUrl}/api/transactions/recent'),
2025-06-30 03:20:49 -07:00
);
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 [];
}
}