The method in my webservice class return data but when I try to access the data by .subscribe method in my component it returns undefined.
The code of method in my service class. I am getting data in this method. And I can see it using console.log.
getData() {
return this.networkService
.getRequest("clienti/v1/session")
.pipe(
map(
(data) => {
console.log("getData");
console.log(JSON.stringify(data));
return data;
}
},
(error) => {
console.log("getData error");
console.log(error);
}
)
);
}
The code in my component class, I am getting undefined here in console.log:
recoverData() {
this.dataService.getData().subscribe(
(data) => {
console.log("data");
console.log(data);
},
(error) => {
console.log(error);
}
);
}
If someone knows what is the problem then please let me know.