2022-05-29 12:12:05 +00:00
|
|
|
import 'package:f0ckapp/model/item.dart';
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
|
|
|
Future<List<Item>> fetchDataFromApi() async {
|
2022-05-29 13:14:58 +00:00
|
|
|
final response = await http.get(Uri.parse('https://f0ck.dev/api/v2/items/get?mode=0'));
|
2022-05-29 12:12:05 +00:00
|
|
|
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
}
|