I’ve been trying to code something to copy the members when they been created or updated , but always get error , could help me please ? I’m new in javascript and I tried the same function in api and get error https://www.wix.com/velo/reference/wix-members-backend/events/onmembercreated
I tried to get imports but not working. The fuction works perfectly woth object intern but not with external object
This is my code :
import wixData from 'wix-data';
import wixMembersBackend from 'wix-members-backend';
import wixMembers from 'wix-members';
import { authentication, authorization, badges, currentMember, members, Events } from 'wix-members-backend';
export function wixMembers_onMemberCreated(event) {
debugger;
const userId = event.entity._id;
let creationEventId = event.metadata.id;
let name = event.entity.profile.nickname;
let loginEmail = event.entity.loginEmail;
let phone = event.entity.contactDetails.phones;
console.log(userId);
console.log(creationEventId);
console.log(name);
console.log(phone);
let toSave = {
"_id": userId,
"name":name,
"email":loginEmail};
console.log(toSave);
debugger;
wixData.save("testes_rapha/Contacts", toSave)
.then( (results) => {
let item = results; //see item below
} )
.catch( (err) => {
let errorMsg = err;
} )}
export function wixMembers_onMemberUpdated(event) {
debugger;
const userId = event.entity._id;
let creationEventId = event.metadata.id;
let name = event.entity.profile.nickname;
let loginEmail = event.entity.loginEmail;
let phone = event.entity.contactDetails.phones;
console.log(userId);
console.log(creationEventId);
console.log(name);
console.log(phone);
let toSave = {
"_id": userId,
"name":name,
"email":loginEmail};
console.log(toSave);
debugger;
wixData.save("testes_rapha/Contacts", toSave)
.then( (results) => {
let item = results; //see item below
} )
.catch( (err) => {
let errorMsg = err;
} )}