Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {"_body":"{"values": {"user_id":"1","name":"fred test","email":"fred@test.test","username":"fredtest","token":"d5f66a06ec809d70d0c52842df8dc0011d7d1ad0f2d56f50d3123da17a2489fe"}}","status":200,"ok":true,"statusText":"OK","headers":{"pragma":["no-cache"],"content-type":["text/html;charset=UTF-8"],"cache-control":["no-store"," no-cache"," must-revalidate"],"expires":["Thu"," 19 Nov 1981 08:52:00 GMT"]},"type":2,"url":"http://localhost/PHP-Slim-Restful/api/login"}
- login(){
- console.log('login'+ this.userData);
- // Your app login API web service call triggers
- this.authService.postData(this.userData,'login').then((result) => {
- this.responseData = result;
- console.log('userdata : '+ temp);
- if(this.responseData.values){
- console.log('response: ' + this.responseData);
- localStorage.setItem('userData', JSON.stringify(this.responseData));
- this.navCtrl.push(TabsPage);
- }
- else{
- this.showToastWithCloseButton()
- }
- }, (err) => {
- console.log('erreur : '+err);
- });
- import {Http, Headers, Response, RequestOptions} from '@angular/http';
- import {Observable} from 'rxjs/Rx';
- var response = this.service.post('deleteUserDetails/'+this.selectedUserId, null);
- response.subscribe((res) => {
- var response = res.json();
- });
- post(url: string, data : any): Observable<any> {
- let headers = new Headers();
- headers.append('Content-Type', 'application/json');
- let options = new RequestOptions({ headers: headers});
- return this.http.post(url, data,{headers: headers});
- }
- public postData(data, url: string) {
- this.http.post(url, data).toPromise().then(res => {
- let responseData = res.json();
- if (responseData) {
- for (var item of responseData) {
- //Implments
- }
- }
- }, (err) => {
- });
- }
Add Comment
Please, Sign In to add comment