0
항상 구독중인 geeting이므로 게시 서비스에서 데이터를 반환 할 수 있습니까? 심지어 나는 그것을 할 수 없다는 내 애플 리케이션 구성 요소를 변환하려고합니다.서비스에서 json 데이터를 반환하는 방법
facility_sevice.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();
}
);
}
facility_component.ts
savePatient() {
const response =
this.facilityService.saveFacility(this.facilityForm.value)
console.log(response);
}
나는 sbscription 객체를 얻고 있지만 JSON으로 반환합니다.