【发布时间】:2021-08-31 17:40:36
【问题描述】:
我已经创建了自定义发布方法,其签名与原来的几乎相同,
postcall(url: string, body: any | null, options: {headers?: HttpHeaders | {
[header: string]: string | string[];
};
params?: HttpParams | {
[param: string]: string | string[];
};
reportProgress?: boolean;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
withCredentials?: boolean;
} = {}): Observable<any> {
return this.http.post<any>(url,body,options.Headers?Headers:responseType);
}
我无法通过上述 post call 传递选项作为参数。请告诉我如何传递参数。它应该传递我们在 postcall() 的正式参数中收到的选项。
编辑-1,
我的电话是
this.http.postcall(this.resumeapiserver,body,{responseType: 'text'});
或
httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
})
}
this.http.postcall(this.apiServer + '/applicants/', JSON.stringify(applicant), this.httpOptions)
这两个都应该工作..
【问题讨论】:
-
向我们展示更多代码.. 请向我们展示您希望通过邮寄方式发送的选项
-
@manzapanza 我的电话会是这样的,this.http.postcall(this.apiServer + '/applicants/', JSON.stringify(test), this.httpOptions) 或 this.http.postcall (this.apiserver,body,{responseType: 'text'});这两个电话都应该工作
-
为了帮助我们帮助您,您应该使用所有相关代码编辑您的问题.. 我建议您删除您放在那里的代码,并放置没有的真实代码作品
-
@manzapanza 已编辑,请再检查一次。