Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.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/0/docker/9.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
angular2 http.get返回错误404?_Angular - Fatal编程技术网

angular2 http.get返回错误404?

angular2 http.get返回错误404?,angular,Angular,角ts码 this.http.get('http://localhost:8000/heroes.json') .map(res => res.text()) .subscribe( data => this.randomQuote = data, err => this.logError(err), () => console.log('Random Quote Complete') ); 但有一个错误: 您已将locat主机放在url中,而不是local主机 作为

角ts码

 this.http.get('http://localhost:8000/heroes.json')
.map(res => res.text())
.subscribe(
data => this.randomQuote = data,
err => this.logError(err),
() => console.log('Random Quote Complete')
);
但有一个错误:


您已将locat主机放在url中,而不是local主机

作为此类问题的提示,如果您确认URL在浏览器中工作,请将其复制并粘贴到代码中,以确保您使用的内容与您确认的工作内容相同