Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import { Injectable } from '@angular/core';
  2. import { AuthData } from './auth/auth-data.model';
  3. import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpClient } from '@angular/common/http';
  4. import { Observable } from 'rxjs';
  5.  
  6. @Injectable({
  7. providedIn: 'root'
  8. })
  9. export class BackendService {
  10.  
  11. private backendHost: String = 'http://localhost:5000';
  12.  
  13. constructor(private http: HttpClient) {
  14. }
  15.  
  16. /* Authentication */
  17.  
  18. registerUser(authData: AuthData) {
  19. return this.http.post(this.backendHost + '/register', authData);
  20. }
  21.  
  22. loginUser(authData: AuthData) {
  23. return this.http.post(this.backendHost + '/auth', authData);
  24. }
  25.  
  26. /* Products */
  27.  
  28. createProduct(products: any[]) {
  29. return this.http.post(this.backendHost + '/product', products[0]);
  30. }
  31.  
  32. deleteProduct(product_id: Number) {
  33. return this.http.delete(this.backendHost + '/product/' + product_id);
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement