Post request in Service
getCollegeList(dataJson: string) {
const model: Subject = new Subject();
this.http.post(this.API_URL + "/cs/searchByMarks",dataJson,{'headers':this.headers}).subscribe((res) => {
// console.log(res);
model.next({data:res})
});
console.log(model)
return model
}
Getting results in Component
sendSubjectDetails() {
console.log("on submit")
const data = this.subjectForm.value;
const dataJson = JSON.stringify(data)
console.log(dataJson)
this.service.getCollegeList(dataJson).subscribe((res) => {
console.log(res.data);
});
// this.service.getCollegeList(dataJson);
}
Headers in Service
API_URL = environment.apiUrl;
headers = { 'content-type': 'application/json'}
No comments