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:
TypeScript
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.
TL;DR
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.You're doing requests with the API?
I suggest using the SDK for flutter since it will handle sessions, etc.
Anyways, what are the requests that you're performing?
Recommended threads
- Errore 403
Ho errore 403 ma il package name è corretto
- Cannot create sites using Flutter framew...
Cannot goto next step, it shows error "missing buildRuntime". I need to select "other" framework then deploys fail, go back to site settings and change "other" ...
- Appwrite mariadb container suddenly usin...
I'm hosting an instance of appwrite since months and updated to 1.8.0 couple of weeks ago. Everything worked fine, but today I noticed that my server is lagging...