tellitabie

Service

Mar 5th, 2021
485
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Injectable } from '@angular/core';
  2. import {Observable} from "rxjs";
  3. import {HttpClient} from "@angular/common/http";
  4. import {catchError, map, tap} from "rxjs/operators";
  5.  
  6. @Injectable({
  7.   providedIn: 'root'
  8. })
  9. export class ProductService {
  10.  
  11.   productUrl = 'http://127.0.0.1:8000/product/';
  12.  
  13.   constructor(private http: HttpClient) { }
  14.   getProducts(): Observable<any[]>{
  15.     return this.http.get<any[]>(this.productUrl);
  16.  
  17.   }
  18.  
  19.   getProductDetails(productId): Observable<any>{
  20.     return this.http.get<any>(`${this.productUrl}${productId}`);
  21.     console.log(this.http.get<any>(`${this.productUrl}${productId}`));
  22.   }
  23.  
  24.   getProduct(id: number): Observable<any> {
  25.     const url = `${this.productUrl}${id}`;
  26.     return this.http.get<any>(url);
  27.   }
  28.  
  29. }
  30.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×