mirror of
https://github.com/supleed2/ELEC60013-ES-CW1.git
synced 2024-12-23 05:55:49 +00:00
25 lines
674 B
Dart
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 [];
|
|
}
|
|
}
|
|
} |