Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. const headers: Headers = new Headers();
  2. headers.append('Content-Type', 'application/json');
  3. headers.append('Authorization', 'Bearer: 123213');
  4. this.http.post('https://127.0.0.1:502', JSON.stringify(token), {headers: headers}).subscribe();
  5.  
  6. import {Http, Headers, RequestOptions} from '@angular/http';
  7.  
  8. export class AppComponent {
  9. constructor(private http: Http) {
  10. let headers = new Headers();
  11. headers.append('Content-Type', 'application/json');
  12. headers.append('authentication', `hello`);
  13.  
  14. let options = new RequestOptions({headers: headers});
  15. this.http.post(
  16. "http://localhost:3000/contacts",
  17. JSON.stringify({id: 4, name: 'some'}),
  18. options
  19. ).subscribe();
  20.  
  21. import {Http, Headers, RequestOptions} from '@angular/http';
  22.  
  23. constructor(private http: Http) {
  24. this.headers = new Headers();
  25. this.headers.append('content-type', 'application/json');
  26. }
  27.  
  28. return this.http.post(url, jsonData, this.headers).map((resp: Response) => resp.json());
  29.  
  30. login(credintials: Authenticate): Observable<any> {
  31.  
  32. const body = {
  33. username: credintials.username,
  34. password: credintials.password,
  35. grant_type: 'password',
  36. client_id: credintials.client_id
  37. };
  38. const headers = new HttpHeaders()
  39. .set('Content-Type', 'application/x-www-form-urlencoded')
  40. .set('Authorization', 'Basic loremlorem');
  41.  
  42. return this.http.post(`${baseUrl}/uaa/oauth/token`,
  43. body,
  44. {
  45. headers: headers
  46. }
  47. );
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement