I have a little bit of code where I need to set some prices depending on the user's pricing plan, but I also need to set a different price if the user isn't "subscribed".
What is the best way to do this?
I'm struggling because user.getPricingPlans() returns a promise, but if the user doesn't have a pricing plan then it doesn't parse the code within the .then at all.
user.getPricingPlans() // is user is not subscribed, then the below is ignored. GRRR!!
.then( (pricingPlans) => {
let firstPlan = pricingPlans[0];
let planName = firstPlan.name;
let fee = 95;
switch (planName) {
case "Plan 1":
fee = 70;
break;
case "Plan 2":
fee = 50;
break;
}
} );