Itempage
This commit is contained in:
15
lib/api/fetchitem.dart
Normal file
15
lib/api/fetchitem.dart
Normal file
@ -0,0 +1,15 @@
|
||||
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');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user