Angular http post请求返回
请求代码:
searchDicts(req?: any): Observable<EntityArrayResponseType> {
const aa = this.http
.post<IDict[]>(this.searchUrl, req, {observe: 'response'})
.pipe(res => {return res});
aa.subscribe(res => {
console.log(res);
});
return aa;
}
问题描述:
如果不加参数{observe: 'response'},返回获取的数据res则是响应体,没有头信息等
如果加了 参数{observe: 'response'},会返回完整的数据,包括响应体,头信息等,这样信息就比较完整