Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { HttpClient, HttpHeaders } from '@angular/common/http';
- import 'rxjs/add/operator/toPromise';
- import { Injectable } from '@angular/core';
- import { Api } from '../api/api';
- import { Storage } from '@ionic/storage';
- import { environment } from '../../environment';
- @Injectable()
- export class User {
- private API_URL: string = 'https://api.corretoradinamica.com/wp-json/wp/v2/';
- public Users: any = [];
- api_url = environment.site_url + environment.jwt_url;
- // _user: any;
- public storage: Storage;
- constructor(public http: HttpClient, public api: Api) { }
- postLogin(username, password) {
- let data = {
- username: username,
- password: password,
- };
- let headers = new HttpHeaders();
- headers.set('Contetn-Type', 'application/json');
- return this.http.post(this.api_url, data, { headers: headers })
- }
- get(query: string = '') {
- return this.http.get(this.API_URL + query);
- }
- getUsers() {
- this.get('users').subscribe((data => {
- this.Users = data;
- }));
- }
- }
Add Comment
Please, Sign In to add comment