rup*_*ram 3 mean ionic2 angular
我得到了运行时错误:
无法在'XMLHttpRequest'上执行'open':无效的URL错误:无法在'XMLHttpRequest'上执行'open':无效的URL位于http:// localhost:8100/build/polyfills.js:3:2793, 位于XMLHttpRequest.open (eval at s(http:// localhost:8100/build/polyfills.js:2:29793),:3:31)
import { Injectable } from '@angular/core';
import { Http, Headers } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class Reviews {
data: any;
constructor(public http: Http) {
this.data = null;
}
getReviews(){
if (this.data) {
return Promise.resolve(this.data);
}
return new Promise(resolve => {
this.http.get('http://localhost:app/api/reviews')
.map(res => res.json())
.subscribe(data => {
this.data = data;
resolve(this.data);
});
});
}
createReview(review){
let headers = new Headers();
headers.append('Content-Type', 'application/json');
this.http.post('http://localhost:app/api/reviews', JSON.stringify(review), {headers: headers})
.subscribe(res => {
console.log(res.json());
});
}
deleteReview(id){
this.http.delete('http://localhost:app/api/reviews/' + id).subscribe((res) => {
console.log(res.json());
});
}
}
Run Code Online (Sandbox Code Playgroud)
Que*_*tin 15
Run Code Online (Sandbox Code Playgroud)http://localhost:app/api/reviews
这是一个无效的URL(就像错误消息所示).
如果您有一个:主机名后面,它必须后跟一个NUMBER端口(然后是路径).app不是数字,而是三个字母.
| 归档时间: |
|
| 查看次数: |
22797 次 |
| 最近记录: |