Reputation: 825
I have a flask application running in this url http://127.0.0.1:5000/SectionA I am returning the data in json format using return jsonify(data).When I hit the url from the browser it looks like this
I am calling this url from the angular application main-service.ts file like this
public getVamData(id,section): Observable<any> {
try {
console.log("I am here getVAM");
return this.http.get('http://localhost:5000/SectionA')
.map((response: Response) => {
console.log("I am here getVAM2");
return response.json();
}
);
}
catch(e) {
console.log('Error:', e);
} }
But the url is not hitting the flask application. Please let me know what I am missing.
Upvotes: 0
Views: 270
Reputation: 774
you have to subscribe the Observable because Observable are lazy loaded. and if you are using getVamData() method of service in somewhere else(like components) then subscribe there. use like this
this.mainService.getVamData(this.paramData.Eid,'SectionA')
.subscribe(result=>{
this.data=result;
console.log(this.data);
})
Upvotes: 1