16 lines
506 B
Dart
16 lines
506 B
Dart
import 'package:f0ckapp/model/item.dart';
|
|
import 'dart:convert';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
Future<Item> fetchItemFromApi(id) async {
|
|
final response = await http.get(Uri.parse('https://f0ck.dev/api/v2/item/$id'));
|
|
|
|
if(response.statusCode == 200) {
|
|
//List jsonresponse = json.decode(response.body)['rows'];
|
|
Map<String, dynamic> jsonresponse = json.decode(response.body)['rows'];
|
|
return Item.fromJson(jsonresponse);
|
|
} else {
|
|
throw Exception('failed to load feed');
|
|
}
|
|
}
|