Skip to content

Instantly share code, notes, and snippets.

@iamburakcoskun
Created October 29, 2019 09:25
Show Gist options
  • Save iamburakcoskun/e9af10214d0e3476361c207b1911e48a to your computer and use it in GitHub Desktop.
Save iamburakcoskun/e9af10214d0e3476361c207b1911e48a to your computer and use it in GitHub Desktop.
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { map } from "rxjs/operators";
import { environment } from 'src/environments/environment.prod';
@Injectable({
providedIn: "root"
})
export class AuthService {
constructor(private httpClient: HttpClient) { }
login(model: any) {
return this.httpClient.post(environment.baseUrl + "Authenticate", model).pipe(
map(function(response: any) {
const user = response;
if (user) {
localStorage.setItem("token", user.token);
}
})
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment