import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { Product , Item } from '@ngrx-workshop-app/api-interface' ; import { Observable } from 'rxjs' ; @ Injectable ( { providedIn : 'root' } ) export class CartService { constructor ( private http ) { } getItems ( ) { return this . http . get < Item [ ] > ( 'api/cart' ) ; } addToCart ( productId ) { return this . http . post < Item [ ] > ( 'api/cart' , { productId } ) ; } checkout ( ) { return this . http . delete < Item [ ] > ( 'api/cart' ) ; } }