I want to use data from the first subscribe in the second subscribe. I received response, that have field 'article', and after I have received it, I should do another request to set article.author value.
if (!this.article) {
this.articleSubscription = this.route.paramMap
.pipe(
switchMap(params => {
this.isLoadingInProgress = true;
return this.dataService.getArticleById(params.get('id'));
}),
).subscribe(response => {
this.article = response.currentArticle;
this.article.relatedArticles = response.relatedArticles;
this.userService.getAllUsers$().subscribe(users => {
const author: AlArticleAuthor =
users.find(user => user.id === this.article.userId);
this.article.author = {
firstName: author.firstName,
lastName: author.lastName,
organization: author.organization,
title: author.title,
};
});
this.isLoadingInProgress = false;
super.setTitle(this.article.title);
super.setMetaDescription(this.article.description);
this.changeDetection.markForCheck();
});
}