Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. getToken() {
  2. return this.http.get(this.getServerUrl() + '/token');
  3. }
  4.  
  5. login(username: string, password: string) {
  6. return this.getToken()
  7. .subscrive((response: Response) => {
  8. return this.http.post(this.getServerUrl() + '/login'
  9. , JSON.stringify({username: username, password: passowrd}))
  10. });
  11. }
  12.  
  13. login(username, password) {
  14. event.preventDefault();
  15. this.authService.login(username, password)
  16. .subscribe(
  17. response => {
  18. console.log("success");
  19. },
  20. error => {
  21. console.log(error.text());
  22. }
  23. );
  24. }
  25.  
  26. this.getToken()
  27. .then(response=>{
  28. if(response){
  29. this.http.post ....
  30. }
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement