Adding a labelContact when a button is clicked

Hi,

Some dynamic page was working fine, until I put some code that intends to add a label to the contact when a button is clicked

But when the code is addedd from https://www.wix.com/velo/reference/wix-crm-backend/contacts-obj/labelcontact, multiple " is registered as a static event handler but is not exported from the page code" warnings appear and the dynamic page stop working as it should

I have no clue why that warnings appear, or what is wrong with my code

A hand would be great

at the top of the code ( This line seems to be causing all the trouble )

import { contacts } from 'wix-crm-backend';

when a button is clicked

{myLabelContactFunction()} ;

function myLabelContactFunction() {
 const contactId = userId;
 const labelKeys = [
 "Clubbituser",
 ];
 const options = {
    suppressAuth: false
 };
 return contacts.labelContact(contactId, labelKeys, options)
 .then((labeledContact) => {
 return labeledContact;
 })
 .catch((error) => {
      console.error(error);
 });
}

Perhaps first taking the easier front-end-way? (not tested)!

import { contacts } from 'wix-crm';

{myLabelContactFunction()};


function myLabelContactFunction(){
 const contactInfo = {
  name:   { first: "Ari", last: "Thereyet"},
  emails: [{email: "xxx@zzz.de"}, 
           {email:"xxx@xxx.com"}
          ],
  phones: [ { tag: "xxx",
              countryCode: "xxx",
              phone: "xxx",
              primary: true
            }
          ],
  labelKeys = ["Clubbituser"];
};

 contacts.appendOrCreateContact(contactInfo)
 .then((resolvedContact) => {
 return resolvedContact;
 })
 .catch((error) => {console.error(error);});
}