Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49358

[object promise] promise not resolving

$
0
0

0

I am a IONIC newbie I have following function that returns membership plan.

 

async getMembership(){
await this.Products.WooCommerceAPI().get(‘memberships/plans’).then( (data) => {
this.plans = data.data.map(e => ({

   // used spread method here to call another function that gets the price 
    ...e,
    price: this.getPlanPrice(e.access_product_ids[0]).then(async (res) => {
      return  await res;
    }),
  }));
}).catch((error) => {
  // Invalid request, for 4xx and 5xx statuses
  console.log('Response Status:', error.response.status);
  console.log('Response Headers:', error.response.headers);
  console.log('Response Data:', error.response.data);
})
.finally(() => {
  // Always executed.
});
console.log(this.plans);

}

in this function I used another function that gets price of each membership using ... spread method.

    async getPlanPrice(id): Promise<any> {
    if (id !== undefined) {
      return await this.Products.WooCommerceAPI().get('products/' + id).then(data => {
        return data.data;
      });
    } else {
      return 0;
    }
  }

but the problem is

price: this.getPlanPrice(e.access_product_ids[0]).then(async (res) => {
          return  await res;
        }),

this part return [Object Promise] I have tried everything but can’t get price for example 500 insdeat of this object promise.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49358

Latest Images

Trending Articles



Latest Images