-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 ?