plushteddyOriginal post
Rank 2: Process
Hello, if I run a http request on the web I alway get a xmlhttprequest error, does anybody know how to fix that issue?
code:
Dart
Future<bool> checkName(String name) async { const apiUrl = 'https://...';
try { final response = await http.get(Uri.parse(apiUrl));
if (response.statusCode == 200) { final Map<String, dynamic> data = json.decode(response.body);
// Überprüfe, ob 'names' in den Daten vorhanden ist if (data.containsKey('names')) { return data['names'].contains(name); } else { throw Exception('Ungültiges Format der API-Antwort: \'names\' nicht gefunden.'); } } else { throw Exception('Fehler bei der API-Anfrage: ${response.statusCode}'); } } catch (e) { print('Fehler: $e'); return false; }}```
I know that I am here on the appwrite discord, but I could find help on the internet and other servers.Summary
Developers are experiencing an xmlhttprequest error in Flutter's HTTP package. There is a suggestion to use the SDK for Flutter to handle sessions. One developer is facing an issue with a http request on the web. A code snippet for a function called 'checkName' is provided, where the error occurs.
Solution: The developer can try using Flutter's SDK for better session handling.