【发布时间】:2018-05-29 20:12:18
【问题描述】:
我正在使用 ionic 3 / angular 开发应用程序,但遇到了一个小问题。我正在从服务中发出发布请求,并且正在尝试使用成功回调的返回值。 我收到以下转译错误:
Argument of type 'ArrayBuffer' is not assignable to parameter of type 'Occasion'. Property 'id' is missing in type 'ArrayBuffer'.
导致错误的代码:
this.api.post('occasions', occasion).subscribe(occasion => {
this.myOccasions.unshift(occasion);
this.myOccasionsChanged.next(this.myOccasions);
},
列表this.myOccasions定义为private myOccasions: Occasion[];
我的api服务post函数定义为:
post(endpoint: string, body: any, reqOpts?: any) {
if (!reqOpts) {
reqOpts = {};
}
let headers = {};
this.addAccessTokenToHeaders(headers);
reqOpts.headers = headers;
return this.http.post(this.url + '/' + endpoint, body, reqOpts);
}
你们能给我一些关于如何使类型一致的建议吗?当然,我的 POST 端点会返回一个 OccasionDto 来使用。 干杯!
【问题讨论】:
标签: angular ionic-framework arraybuffer