Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { Http } from '@angular/http';
- import 'rxjs/add/operator/map';
- import { URL_SERVICES } from '../../config/url.services';
- import { AlertController } from 'ionic-angular';
- @Injectable()
- export class UsersProvider {
- token:string;
- id_user:string;
- constructor(public http: Http,
- private alertCtrl: AlertController) {
- console.log('Hello UsersProvider Provider');
- }
- ingresar( email:string, password:string){
- console.log("usersP ",email);
- console.log("usersP ", password);
- let data = new URLSearchParams();
- data.append("email", email);
- data.append("password", password);
- let url = URL_SERVICES + "login";
- return this.http.post( url, data )
- .map( resp => {
- let data_resp = resp.json();
- console.log( data_resp );
- if( data_resp.err ){
- this.alertCtrl.create({
- title: 'Error al iniciar',
- subTitle: data_resp.message,
- buttons: ['OK']
- }).present();
- }else{
- this.token = data_resp.token;
- this.id_user = data_resp.id_user;
- //GUARDAR STORAGE
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment