members.getMember not working from wixPaidPlans_onPlanPurchased( )

when I call

currentMember . getMember ({ fieldsets : [ ‘FULL’ ]})

or

members . getMember ( member . _id , { fieldsets : [ ‘FULL’ ]})

from backend code for a specific member, I get the full set of information for the member.
However, when I call

members . getMember ( event . order . memberId, { fieldsets : [ ‘FULL’ ]})

from within wixPaidPlans_onPlanPurchased ( event ) - in events.js - the returned member object is missing information such as contactDetails.emails.
Don’t know why this is not working here. The order memberId is correct. I have put test code in many other places (outside of events.js) and the member.contactDetails.emails always has the correct info.

Any help would be appreciated as I need the member’s email when processing a paid subscription

Hi Steven :raised_hand_with_fingers_splayed:

The getMember( ) method returns a Promise, and you’re not waiting for it, change the event function into an async function, and add the await keyword before calling the above method.

export async function wixPaidPlans_onPlanPurchased(event) {
    const member = await members.getMember(event.order.memberId, {fieldsets: ['FULL']});
    
    console.log(member); // Should print:
    /* {
        _id: "random_text",
        loginEmail: "email@domain.com",
        status: "APPROVED",
        ....
    } */
}

Hope this helps~!
Ahmad

I do know that it returns a promise and I am waiting for it using .then(member)
It’s the member object itself that is not complete. That is the contactDetails.emails.
is empty (member.contactDetails.emails = [ ] where as in all other calls it has the correct email value.