Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 无法从get方法获取任何数据_Angular_Ionic3_Mean Stack - Fatal编程技术网

Angular 无法从get方法获取任何数据

Angular 无法从get方法获取任何数据,angular,ionic3,mean-stack,Angular,Ionic3,Mean Stack,我无法从get方法获取任何数据。我有一个名为job.ts的页面,在该页面中,我正在调用另一个提供者/服务ts文件中的方法 此处未执行任何操作。Hmm为什么不将请求返回到job.ts并在此处订阅响应?试试这个: getSavedJobList(userId) { let headers = new HttpHeaders(); headers.append('Content-Type','application/json'); return this.http.get(th

我无法从get方法获取任何数据。我有一个名为job.ts的页面,在该页面中,我正在调用另一个提供者/服务ts文件中的方法


此处未执行任何操作。

Hmm为什么不将请求返回到job.ts并在此处订阅响应?试试这个:

getSavedJobList(userId) {
    let headers = new HttpHeaders();
    headers.append('Content-Type','application/json');
    return this.http.get(this.db_url + 'savedjobList/' + userId,{headers: headers});
  }
在job.ts中

async getSavedJobs() {
    let id = await this.profileId();
    this.jobService.getSavedJobList(id).subscribe((list: any) => {
      for (let job of list) {
        this.savedjobs.push(job);
      }
    }).catch((err: any) => {
      console.log('err in getting the saved jobs '+ err);
    });
  }
} 

你能说得更具体些吗?你收到的是什么样的无数据?它是空的json对象还是空的json对象?您是否可以在浏览器中检查您的网络流量,并查看由此收到的错误代码(如果有)?是的,这看起来更正确,您不在General服务组件内部订阅。但是在组件内部,您有您的业务逻辑。以及在哪里使用数据。
async getSavedJobs() {
    let id = await this.profileId();
    this.jobService.getSavedJobList(id).subscribe((list: any) => {
      for (let job of list) {
        this.savedjobs.push(job);
      }
    }).catch((err: any) => {
      console.log('err in getting the saved jobs '+ err);
    });
  }
}