July 2018
Intermediate to advanced
420 pages
8h 46m
English
Our service still has one more function, which we will use to send the user's votes for a specific bike. Remember, whenever you need to use the HTTPClient module, do this within a service. This is considered good practice in Angular development.
Add the following code right after the deleteBike() function:
/** Vote on bike */
voteOnBike (vote: number, bike: number): Observable<any> {
const rating = vote;
return this.http.post(this.bikesUrl + `/${bike}/ratings`, {rating})
.pipe(
catchError(error => this.handleError(error))
);
}
Read now
Unlock full access