我一直在订阅,如何从邮政服务中获取数据返回。即使我尝试在我的应用程序组件中进行转换,我也无法做到。
设施服务.ts
saveFacility(facility) {
const headers = new Headers({'Content-Type': 'application/json'});
return this.http.post('http://localhost:8000/saveFacility',
facility, headers)
.subscribe(
(response: Response) => {
return response.json();
},
(error) => {
return error.json();
}
);
}
设施组件.ts
savePatient() {
const response =
this.facilityService.saveFacility(this.facilityForm.value)
console.log(response);
}
我正在获取 sbscription 对象,但我想以 json 的形式返回。