how to read custom field

Having this API call extracted from the documentation. And trying to read 2 custom fields.

export function myGetProfile() {
  return currentMember.makeProfilePublic()
    .then((profile) => {
    let tblCustom = null; 
      tblCustom = profile.contactDetails.customFields;
      console.log("custom tbl= " + JSON.stringify(tblCustom));  
//   {"custom.type-de-membre":{"name":"Type de membre","value":"Auxiliaire"},"custom.groupe":{"name":"groupe","value":"Membre"}}
      return profile;
    })
    .catch((error) => {
      console.error(error);
    });
}

this is what the console.log is returning

//{"custom.type-de-membre":{"name":"Type de membre","value":"Auxiliaire"},"custom.groupe":{"name":"groupe","value":"Membre"}}

unable to figure out , how can I read the 2 custom field’s value.


I tried with the following code with no success as the pre-compiler is thinking I am doing an arithmetic calculation: the dash are part of the field name generated by Wix.

let a = tblCustom.custom.type-de-membre.value;

Can I have somebody providing me a solution. Thank in advance

Still nobody here :unamused:

Try to reference it like this:
let a = tblCustom[ “custom.type-de-membre” ]. value;

@youge This looks like what you’re looking for here. Let us know if this works

@chris-derrell Thanks, it is working