Last active
August 11, 2021 17:28
-
-
Save bbrt3/449eac35d2c2bb1ea0be1986a6a15e6b to your computer and use it in GitHub Desktop.
TypeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Observables are a representation of any set of values | |
over any amount of time. | |
*/ | |
import {map, tap} from '@rxjs/operators' | |
getOldBookById(id: number): Observable<OldBook>{ | |
return this.http.get<Book>(`/api/books/${id}`) | |
.pipe( | |
map(b => <OldBook>{ | |
bookTitle: b.title, | |
year: b.publicationYear | |
}), | |
tap(classicBook => console.log(classicBook)) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment