How to redirect and send variables of the current logged in correctly?

-1

Hello how are you ? I’m new to javascript and I need help with a question. I’m trying to send data of the current logged in member and redirect a different domain via a button on the website code creation. The data are status, full name, email and id. The language used is javascript. I would like to know what I do to be able to send this data together in the url and what I’m doing wrong in the code.

Note= "www.url. /com "is a example.


 export function button2_click(event) {
  wixLocation.to("www.page. /com" + currentMember.getMember().then((member) => {
      const id = member._id;
      const status = member.statusconst fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
      return member;
    })
    .catch((error) => {
      console.error(error);
    })
  );
}

I tried post it in stackoverflow and receive the answer to fix the code with it :

export async function button2_click(event) {
  const member = await currentMember.getMember();
  const id = member._id;
  const status = member.statusconst fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
  const userDetails = JSON.stringify({id, status, fullName});
  
  wixLocation.to(`www.url./com?user=${encodeURIComponent(userDetails)}`);
}

The both codes have the same errors .
Error: Ambassador client request failed: HTTP STATUS: -1 RESPONSE: “Failed to fetch” See the httpStatus and response fields for more information.

TypeError: Cannot read properties of undefined (reading ‘_id’)

Could you help me please ?

You have some mistakes, but first please show us how the final URL (with all the parameters) should look like.

The other external site don´t have ''www" and it´s a web server application in google cloud. I Think the best option url should be with “url. /com + json arquive because has criptography.
I can´t say the real url here because it´s open. But use the same estruture in this example"cod./ar”
The parameters in json should be full name, id user, status(because this gonna define the type of client) and email.

I figured out the answer, I will copy here too. After a lot of research on the Wix Velo forum, I discovered the members-wix API, at the moment it is having problems, which results in looking for functions in the users-wix API, but it is deprecated, which hides functions on the site the fleece making access to information difficult. However, after copying a migration function from users-wix to members-wix, along with members-wix authentication, it worked perfectly, I also want to thank Mosh Feu for help. There is a copy of code in stackoverflow, I will put the link here
stackoverflow /.com/questions/70771391/how-to-redirect-and-send-variables-of-the-current-logged-in-correctly/70773421#70773421