This commit is contained in:
2022-05-29 14:12:05 +02:00
parent 7d1f000a43
commit 71a5668d90
9 changed files with 348 additions and 72 deletions

14
lib/api/fetchdata.dart Normal file
View File

@ -0,0 +1,14 @@
import 'package:f0ckapp/model/item.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<List<Item>> fetchDataFromApi() async {
final response = await http.get(Uri.parse('https://f0ck.dev/api/v2/items/get?mode=3'));
if(response.statusCode == 200) {
List jsonresponse = json.decode(response.body)['items'];
return jsonresponse.map((tmp) => Item.fromJson(tmp)).toList();
} else {
throw Exception('failed to load feed');
}
}