In my web browser, the Promise object is “fulfilled”, the result is a value, but when I build it in the mobile app the Promise object is “pending” (working), the result is undefined.
Here is my code below
api_url:any;
async getApiURLPromise() {
return await new Promise(resolve => {
this.http.get("https://www.sample_api.com/api/production")
.subscribe(data => {
this.api_url = data['apiurl'];
console.log("PROMISE TO HER THIS API URL - " + this.api_url);
resolve(this.api_url);
});
}).catch(error => {
console.log("PROMISE REJECTED BECAUSE YOU BROKE IT - " + error
+ " - " + JSON.stringify(error));
});
}
1 post - 1 participant