Guest User

Untitled

a guest
Jul 26th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import { HttpClient, HttpHeaders } from '@angular/common/http';
  2.  
  3. import 'rxjs/add/operator/toPromise';
  4. import { Injectable } from '@angular/core';
  5. import { Api } from '../api/api';
  6. import { Storage } from '@ionic/storage';
  7. import { environment } from '../../environment';
  8.  
  9. @Injectable()
  10. export class User {
  11. private API_URL: string = 'https://api.corretoradinamica.com/wp-json/wp/v2/';
  12. public Users: any = [];
  13.  
  14. api_url = environment.site_url + environment.jwt_url;
  15.  
  16. // _user: any;
  17. public storage: Storage;
  18.  
  19. constructor(public http: HttpClient, public api: Api) { }
  20.  
  21. postLogin(username, password) {
  22. let data = {
  23. username: username,
  24. password: password,
  25.  
  26. };
  27. let headers = new HttpHeaders();
  28. headers.set('Contetn-Type', 'application/json');
  29. return this.http.post(this.api_url, data, { headers: headers })
  30. }
  31.  
  32. get(query: string = '') {
  33. return this.http.get(this.API_URL + query);
  34. }
  35.  
  36. getUsers() {
  37. this.get('users').subscribe((data => {
  38. this.Users = data;
  39. }));
  40. }
  41. }
Add Comment
Please, Sign In to add comment