Fix: connection problems checks

This commit is contained in:
2024-05-22 00:49:51 +03:00
parent d8e68f9b34
commit 46ba11cd57

View File

@@ -108,15 +108,19 @@ class _ExamplePageState extends State<ExamplePage> {
Future<String> _getToken() async { Future<String> _getToken() async {
var url = var url =
Uri.http('gymlink.freemyip.com:8080', 'api/auth/authorize_client'); Uri.http('gymlink.freemyip.com:8080', 'api/auth/authorize_client');
var response = await http.post(url, body: { try {
'GymKey': 'eeb42dcb-8e5b-4f21-825a-3fc7ada43445', var response = await http.post(url, body: {
'id': '123' 'GymKey': 'eeb42dcb-8e5b-4f21-825a-3fc7ada43445',
}); // Just testing token 'id': '123'
var decodedBody = jsonDecode(response.body) as Map; }); // Just testing token
if (decodedBody['payload'] == null) { var decodedBody = jsonDecode(response.body) as Map;
if (decodedBody['payload'] == null) {
return '';
}
return decodedBody['payload']['token'];
} catch (e) {
return ''; return '';
} }
return decodedBody['payload']['token'];
} }
@override @override