f0ckapp/lib/api/fetchitem.dart
Flummi ca98d86e26
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Itempage
2022-05-30 02:29:52 +02:00

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');
}
}