i am using the following provider function below to call my api, which it does successfully.
I am calling this function from a provider on anther call.
The output if i am correct is a promise object with a my returned json data. When i look at object using a console.log. I see addtional element before my data e.g. __zone_symbol__value.
How do i get the json as i would need it?
gateway_list(){
return new Promise(resolve => {
this.http.get(this.Gateway_List_api,{
headers: new HttpHeaders().set('ZUMO-API-VERSION','2.0.0'),
params: new HttpParams().set('id', this.My_login_ID),
})
.subscribe(data => {
resolve(data);
console.log(data);
}, err => {
console.log(err);
});
});
}
}
Replace string[] with whatever business object interface you might prefer.
Never subscribe in the same place an Observable is created, so the subscribe call is going to be in whoever is callinggatewayList(), and in there is the data you want.
The answer to what appears to be your larger question of âhow do I make asynchronous things work synchronously, because all this asynchronous stuff makes my head spinâ is really âyou canâtâ, and there isnât really any substitute for taking the time to slog through learning rx from places such as here.