【发布时间】:2017-06-08 23:35:11
【问题描述】:
我正在我的 Angular 2 应用程序中构建一个 RESTful 服务以连接到远程后端。
我的 GET (all) /POST 方法似乎没问题,我的 PUT 方法似乎没问题,但是我的 GET(单个对象)方法,看起来就像 PUT 方法,抛出上述错误:提供的参数做与调用目标的任何签名都不匹配。
这会在编译过程中引发错误:
getCourse (course: Course): Observable<Course> {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
let courseUrl = this.BaseUrl + '/' + course.id;
return this.http.get(courseUrl, { course }, options)
.map(this.extractData)
.catch(this.handleError);
}
这行得通:
put(course: Course): Observable<Course> {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
let courseUrl = this.BaseUrl + '/' + course.id;
return this.http.put(courseUrl, { course }, options)
.map(this.extractData)
.catch(this.handleError);
}
想法?我做错了什么?
【问题讨论】:
标签: angular typescript rxjs angular2-observables