Here by using GET
method, I'm getting the applied jobs list. This code is from appliedJobsPage
this.getjobs.getAppliedjobList().subscribe(data => {
this.appliedjobs = data;
})
This is my provider page getJobs
getAppliedjobList() {
let headers = new Headers();
headers.append('Content-Type','application/json');
return this.http.get('http://localhost:3000/api/appliedjobs',{headers: headers})
.map(res => res.json())
.subscribe(data => {
this.jobslist = data;
});
}
I'm getting error as
Property 'subscribe' does not exist on type 'Subscription'. Did you mean 'unsubscribe'?
You're having this error because you have already subscribed to the observable.
map(res => res.json())
.subscribe(data => {
this.jobslist = data;
});
If you're using angular version 5 or later you don't need this map(res => res.json())
. At any rate, you need to remove the subscription to the observable in your service so that you can subscribe to the observable in your component. Remove the following in your service:
.subscribe(data => {
this.jobslist = data;
});
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加