I have a very simple service.ts
file. I can console log the responeDataSent
object.
CallFunction() {
this.http
.post<{ someObject: any }>(
'http://localhost:3000/apicall1',
InputData
)
.subscribe(responseData => {
this.responeDataSent = responseData;
return this.responeDataSent;
});
}
In my component.ts
file, how can I read this response
. Please help.
private context: any;
ngOnInit() {
this.context = this.service.CallFunction();
console.log(this.context); // comes undefined.
}