How do you extract the value inside the subscribe on angular.
I have this code:
async trackingInfo(trackingNumber) {
const foo = await this.userService
.trackOrderStatus(trackingNumber)
.subscribe((status) => {
console.log(status, 'stat');
return status;
});
console.log(foo, 'grrr');
}
foo
returns the subscription not the status
I know theres away not to use async await but i totally forgot. much appreciate the help. thanks
Assign it to something in the subscribe block:
status: any;
trackingInfo(trackingNumber) {
const foo = this.userService
.trackOrderStatus(trackingNumber)
.subscribe((status) => {
console.log(status, 'stat');
this.status = status;
});
console.log(foo, 'grrr');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.