On the end i need response from
BOTH requests, but need chain them, because second request need something from first response.
import { switchMap, map } from 'rxjs/operators';
this.restService.getFile(id)
.pipe(
switchMap((file:File) => this.restService.renderMd(file.markdown_id)
.pipe(map((markdown:any) => {
return {
file:file,
markdow: markdown
};
}))
)
).subscribe((result:any) => {
// I have results for two requests here
console.log(result);
}); |
import { switchMap, map } from 'rxjs/operators';
this.restService.getFile(id)
.pipe(
switchMap((file:File) => this.restService.renderMd(file.markdown_id)
.pipe(map((markdown:any) => {
return {
file:file,
markdow: markdown
};
}))
)
).subscribe((result:any) => {
// I have results for two requests here
console.log(result);
});