July 2018
Intermediate to advanced
420 pages
8h 46m
English
As we mentioned earlier, CRUD stands for Create, Read, Update, and Delete. We will add the code for the operations all at once, and then we will make the necessary comments.
Add the following blocks of code right after the constructor() function:
/** GET bikes from bikes endpoint */ getBikes (): Observable<Bike[]> { return this.http.get<Bike[]>(this.bikesUrl) .pipe( catchError(error => this.handleError(error)) ); } /** GET bike detail from bike-detail endpoint */ getBikeDetail (id: number): Observable<Bike[]> { return this.http.get<Bike[]>(this.bikesUrl + `/${id}`) .pipe( catchError(error => this.handleError(error)) ); } /** POST bike to bikes endpoint */ addBike (bike: Bike): Observable<Bike> { return this.http.post<Bike>(this.bikesUrl, ...Read now
Unlock full access