我使用一种方法将数据发送到服务器端,但是当我使用 GET 方法时,请求无法到达该服务器,我不知道为什么即使我的代码块看起来也是逻辑的,这是第一个问题,第二个问题只是使用谷歌浏览器,它在其他浏览器上失败,我也不知道为什么,这是方法,谁能告诉我为什么会出现这种行为?
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;
}
我这样称呼它:
request('POST','http://127.0.0.1:1111', data).then((e){
print("result returned is: $e");
});
即使我将它添加到服务器端的标题中,该方法也不会接受“GET”,并且它只适用于我提到的谷歌浏览器!如果有人有更好的解决方案,你能告诉我吗?