0

I am new to flutter and I want to create app that will help me solve chemist equations, for that I created this function:

    void main() {
  String m = "H2O";
  String n = "H2O";
  parser(m, n);
}

parser(m, n) async {
  var client = Client();
  Response response = await client
      .get(Uri.parse('https://chemequations.com/ru/?s=$m+%2B+$n&ref=input'));
  var x = parse(response.body);
  print(x.getElementsByClassName("equation main-equation well")[0].text);
}

This construction works in dart really well and prints in console right result, but in flutter I wanted to use it with SetState method, but I can't even print result in console. It throws an error:

Error: XMLHttpRequest error.

Help me please. Thanks

aNOOBis
  • 70
  • 2
  • 6
  • Take a look at this question, hopefully something here will help you https://stackoverflow.com/questions/60191683/xmlhttprequest-error-in-flutter-web-enabling-cors-aws-api-gateway – h8moss Sep 17 '21 at 17:08
  • that doesn't work... – aNOOBis Sep 18 '21 at 13:35

1 Answers1

0

Error happens because I launched application in web. Just started debugging from mobile emulator and error disappeared

aNOOBis
  • 70
  • 2
  • 6