Guest User

Untitled

a guest
Feb 1st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. POST: http://XX.XX.XX.XX:8081/login
  2.  
  3. body {
  4. username
  5. password
  6. }
  7.  
  8. import { Injectable } from '@angular/core';
  9. import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
  10.  
  11. @Injectable()
  12. export class AuthService {
  13. readonly endpoint = 'http://XX.XX.XX.XX:8081/login';
  14.  
  15. constructor(private readonly httpClient: HttpClient) { }
  16.  
  17. post(userName: string, password: string) {
  18. console.log('AuthService.post has been executed!');
  19.  
  20. const body = new HttpParams()
  21. .set('username', 'name')
  22. .set('password', 'pass');
  23.  
  24. const headers = new HttpHeaders()
  25. .append('Content-Type', 'application/x-www-form-urlencoded');
  26.  
  27. const options = {
  28. headers: headers
  29. };
  30.  
  31. return this.httpClient.post(this.endpoint, body, options);
  32. }
  33. }
Add Comment
Please, Sign In to add comment