Guest User

Untitled

a guest
Feb 22nd, 2018
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. {"_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"}
  2.  
  3. login(){
  4. console.log('login'+ this.userData);
  5. // Your app login API web service call triggers
  6. this.authService.postData(this.userData,'login').then((result) => {
  7. this.responseData = result;
  8.  
  9. console.log('userdata : '+ temp);
  10. if(this.responseData.values){
  11. console.log('response: ' + this.responseData);
  12. localStorage.setItem('userData', JSON.stringify(this.responseData));
  13. this.navCtrl.push(TabsPage);
  14. }
  15. else{
  16. this.showToastWithCloseButton()
  17. }
  18. }, (err) => {
  19. console.log('erreur : '+err);
  20. });
  21.  
  22. import {Http, Headers, Response, RequestOptions} from '@angular/http';
  23. import {Observable} from 'rxjs/Rx';
  24.  
  25. var response = this.service.post('deleteUserDetails/'+this.selectedUserId, null);
  26. response.subscribe((res) => {
  27. var response = res.json();
  28. });
  29.  
  30. post(url: string, data : any): Observable<any> {
  31. let headers = new Headers();
  32. headers.append('Content-Type', 'application/json');
  33.  
  34. let options = new RequestOptions({ headers: headers});
  35. return this.http.post(url, data,{headers: headers});
  36. }
  37.  
  38. public postData(data, url: string) {
  39. this.http.post(url, data).toPromise().then(res => {
  40. let responseData = res.json();
  41. if (responseData) {
  42. for (var item of responseData) {
  43. //Implments
  44. }
  45. }
  46. }, (err) => {
  47.  
  48. });
  49. }
Add Comment
Please, Sign In to add comment