25 lines
783 B
Dart
25 lines
783 B
Dart
|
import 'dart:convert';
|
||
|
import 'package:http/http.dart' as http;
|
||
|
|
||
|
import 'package:unit2/model/passo/signatories.dart';
|
||
|
|
||
|
class SignatoriesServices {
|
||
|
static final SignatoriesServices _instance = SignatoriesServices();
|
||
|
static SignatoriesServices get instance => _instance;
|
||
|
|
||
|
Future<List<Signatories>> getSignatories() async {
|
||
|
http.Response response = await http.get(
|
||
|
Uri.parse('http://192.168.10.218:8000/api/rptass_app/signatories/'));
|
||
|
print('Signatories');
|
||
|
print(response.statusCode);
|
||
|
if (response.statusCode == 200) {
|
||
|
final List result = jsonDecode(response.body)['data'];
|
||
|
|
||
|
return result.map(((e) => Signatories.fromJson(e))).toList();
|
||
|
} else {
|
||
|
print(response.reasonPhrase);
|
||
|
throw Exception(response.reasonPhrase);
|
||
|
}
|
||
|
}
|
||
|
}
|