回复请求没有回应?

时间:2019-06-04 12:10:58

标签: ionic-framework

回应中有问题吗?

import { Component } from '@angular/core';
import { ActivatedRoute, Router, NavigationExtras } from '@angular/router';
import { ToastController, NavController } from '@ionic/angular';
import { HttpClient, HttpHeaders } from '@angular/common/http';

@Component({ selector: 'app-tab1',
             templateUrl: 'tab1.page.html',  
             styleUrls: ['tab1.page.scss']
})
export class Tab1Page 
{
     apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
     apiUrl ='http://api.watchover247.com/api/users/authenticated_user';
     data1: any;
     Data: any; 

     constructor(private route: ActivatedRoute,
                 public router: Router, 
                 public toastCtrl: ToastController,
                 public http:HttpClient) { 
         this.route.queryParams.subscribe(params => {
                  console.log("params: ",params); 
                  if(params && params.special) {
                     this.data1 = JSON.parse(params.special);
                  }

                  if(this.router.getCurrentNavigation().extras.state) {
                     this.data1 = this.router.getCurrentNavigation().extras.state.user;
                  } 
         });  
    } 

    ngOnInit() {
         var headers = new HttpHeaders({'x-watchover-key': this.apiKey});
         let body = { auth_email:"gurnaibsingh0015@gmail.com" }
         this.http.post(this.apiUrl,body, {headers: headers}).subscribe
              (data => { this.Data = data; console.log(data); }, 
               error => {console.log(error);
         }); 
    }
}

0 个答案:

没有答案