feat: add Flutter web frontend with authentication and recipe management features
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import 'dart:convert';
|
||||
import '../../../core/api/api_client.dart';
|
||||
import '../domain/recipe.dart';
|
||||
|
||||
class RecipeRepository {
|
||||
final ApiClient _api;
|
||||
|
||||
RecipeRepository(this._api);
|
||||
|
||||
Future<List<Recipe>> fetchRecipes({String? token}) async {
|
||||
final response = await _api.get('/api/recipes', token: token);
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('Failed to load recipes: ${response.statusCode}');
|
||||
}
|
||||
final List<dynamic> data = jsonDecode(response.body) as List<dynamic>;
|
||||
return data
|
||||
.map((e) => Recipe.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user