ELEC60013-ES-CW1/App/lib/service/auth_service.dart
2022-03-07 23:28:43 +00:00

25 lines
674 B
Dart

import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:leg_barkr_app/utils/endpoints.dart' as Endpoints;
class AuthService{
Future<List<String>> getUserDevices(String uid) async {
final response = await http.get(
Uri.parse(Endpoints.getUserDevices),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'UID': uid,
},
);
if (response.statusCode == 200){
List<dynamic> list = jsonDecode(response.body)['devices'];
List<String> res = [];
for (final l in list) {
res.add(l.toString());
}
return res;
} else{
return [];
}
}
}