'Getting XMLHttpRequest error while fetching data from website in Flutter
So I got this "XMLHttpRequest" error and I've been trying to fix it for hours without any results. Here is my code:
var response = await http.get(Uri.https('sigarra.up.pt','feup/pt/cantina.ementashow#7'));
var jsonData = jsonDecode(response.body);
print(jsonData);
I have more code, but at the moment I'm just trying to see if it gets the information from the website, which apparently doesn't do it.
Can someone point me in the right direction? I would appreciate any help.
Solution 1:[1]
import 'package:wnetworking/wnetworking.dart';
void main(List<String> arguments) async {
var raw = await HttpReqService.get<String>(
'https://sigarra.up.pt/feup/pt/cantina.ementashow#7',
jsonResponse: false,
);
print(raw?.substring(0,200));
}
Output:
<!DOCTYPE html>
<html lang="pt" dir="ltr">
<head>
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png" /><link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ουιλιαμ ΑÏκευα |