Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Injectable } from "@angular/core";
  2. import { HttpClient } from "@angular/common/http";
  3.  
  4. import { User } from "../models/user";
  5.  
  6. @Injectable({ providedIn: "root" })
  7. export class UserService {
  8.   constructor(private http: HttpClient) {}
  9.  
  10.  
  11.   getById(id: string) {
  12.     return this.http.get<User>(`http://localhost:3000/users/${id}`)
  13.   }
  14.  
  15.   checkIn(user: User) {
  16.     return this.http.post('http://localhost:3000/checkIn', user);
  17.   }
  18.  
  19.   checkOut(user: User) {
  20.     return this.http.post('http://localhost:3000/checkOut', user);
  21.   }
  22.  
  23.   getAll() {
  24.     return this.http.get<User[]>(`http://localhost:4200/users`);
  25.   }
  26.  
  27.   register(user: User) {
  28.     return this.http.post(`http://localhost:4200/users/register`, user);
  29.   }
  30.  
  31.   delete(id: number) {
  32.     return this.http.delete(`http://localhost:4200/users/${id}`);
  33.   }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement