I am trying to fetch a simple JSON file from my HTTPS server in flutter web however, it doesn't fetch the JSON and simply prints :-
Error code: XMLHTTPRequest error
How do I fix this issue? Here's my code -
Future<List<GamesJSON>> fetch(String link) async {
final res = await get(Uri.parse(link));
if (res.statusCode == 200) {
final data = json.decode(res.body);
final rest = data;
list = rest.map<GamesJSON>((json) => GamesJSON.fromJson(json)).toList()
as List<GamesJSON>;
}
return list;
}