Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么HttpRequest在Dart中返回ProgressEvent错误_Http_Dart - Fatal编程技术网

为什么HttpRequest在Dart中返回ProgressEvent错误

为什么HttpRequest在Dart中返回ProgressEvent错误,http,dart,Http,Dart,我想在dart中进行http调用,但有些站点在我尝试时返回ProgressEvent错误,有些则没有。我不明白 导入'dart:html'; void main()异步{ 打印(等待HttpRequest.getString('https://swapi.co/api/people/1')); } 我预计产量为 { "name": "Luke Skywalker", "height": "172", "mass": "77", "hair_color": "blond", "skin_col

我想在dart中进行http调用,但有些站点在我尝试时返回ProgressEvent错误,有些则没有。我不明白

导入'dart:html';
void main()异步{
打印(等待HttpRequest.getString('https://swapi.co/api/people/1'));
}
我预计产量为

{
"name": "Luke Skywalker",
"height": "172",
"mass": "77",
"hair_color": "blond",
"skin_color": "fair",
"eye_color": "blue",
"birth_year": "19BBY",
"gender": "male",
"homeworld": "https://swapi.co/api/planets/1/",
"films":[
"https://swapi.co/api/films/2/",
"https://swapi.co/api/films/6/",
"https://swapi.co/api/films/3/",
"https://swapi.co/api/films/1/",
"https://swapi.co/api/films/7/"
],
"species":[
"https://swapi.co/api/species/1/"
],
"vehicles":[
"https://swapi.co/api/vehicles/14/",
"https://swapi.co/api/vehicles/30/"
],
"starships":[
"https://swapi.co/api/starships/12/",
"https://swapi.co/api/starships/22/"
],
"created": "2014-12-09T13:50:51.644000Z",
"edited": "2014-12-20T21:17:56.891000Z",
"url": "https://swapi.co/api/people/1/"
}
但回报是有限的

Uncaught Error: Instance of 'ProgressEvent'
在我的测试中,这取决于url:如果我尝试使用相同的代码,但url为:,则json成功加载。
您是否尝试设置允许COR? 我的REST服务器也有同样的问题,我允许使用CORS源代码,它成功了! 您可以使用以下网站: 使用此页面测试CORS请求