0

I use a method to send data to the server side but when I use GET method the request fails to reach that server and I don't know why even the block of my code seems logic, that was the first problem the second one it's only working with Google browsers and it fails on the other browsers and I also don't know why, here is the method, can anyone tells me why this behavior?

 Future<String> request(String method, String url, String requestData) {
        Completer completer = new Completer<String>();
        req = new HttpRequest()
        ..open(method,url)
        ..onLoad.listen((e) {
            completer.complete(req.responseText);
         })
        ..send(requestData);
        return completer.future;
      }

and i call it this way:

  request('POST','http://127.0.0.1:1111', data).then((e){
      print("result returned is: $e"); 
  });

the method won't accept 'GET' even when I add it in the headers on the server side, and it'll work only with google browsers as i mentioned! and if someone have a better solution can you please tell me ?

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Saïd Tahali
  • 189
  • 10

1 Answers1

0

I think the onLoadEnd event would be more appropriate to complete the completer.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567