I am learning RxJS. I have 2 api, based on data of 1st api, I have to call second api and return the value. I did with subscribe() method like this:
checkPermission(permissionName: string): Observable<boolean> {
this.checkCompanySettingForPermission(
this.pageLevelCompanySettingName
).subscribe(res => {
const shouldCheck = res.Value;
if (shouldCheck.toLowerCase() === "true") {
this.hasPermission(permissionName).subscribe(res => {
this.$permissionSub.next(res.permission);
});
} else {
this.$permissionSub.next(true);
}
});
return this.$permissionSub.asObservable();
}
I want to avoid subscribe() method in another subscribe() method. Can I do with any operator of RxJS?
I tried it with switchMap() also but getting lots of syntax error. Please help.