import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; import { Observable } from 'rxjs/Observable'; import { environment } from '../../../environments/environment'; export class Auth { code: number; message: string; } @Injectable() export class AuthService { isLoggedIn = false; // store the URL so we can redirect after logging in redirectUrl: string; constructor(private http: HttpClient, private router: Router) { } login(body: any, url?: string) { return this.http.post(`${environment.url}/login`, body); } logout() { return this.http.get(`${environment.url}/logout`); } }