离子 3 使用 header 令牌调用 api

ionic 3 call api with header token

我有 api url 和令牌。在邮递员中,api 工作正常并显示数据。我需要在控制台的 ionic 3 应用程序中显示数据,有人知道我该如何显示吗?我试过了,但它显示错误。

api: http://api.igiinsurance.com.pk:8888/insurance_takaful/insurance-api/get_panel_hospitals.php?offset=0&limit=100

令牌:ee66cf61762eab785b006186dbc8c980

邮递员截图:

我尝试使用此代码但无法正常工作。

  getDataUsingToken1(token) { 
    const httpOptions = {headers: new HttpHeaders().set("Authorization", "token "+token)}; 
     return this.httpClient.get('this.apiurl', httpOptions) 
  }; 

  ngOnInit() { 
    this.getDataUsingToken1(this.token).subscribe(data=>{ 
      console.log(data); 
    },
    err => console.log(err.message)
    );
  } 

试一试:

getDataUsingToken1(token) { 
         return this.httpClient.get(this.apiurl,{headers:new HttpHeaders({
                  'token': token
                })) 
      }