I am trying to grab current users userid and insert it into a new connection. I have seen several similar discussions on forums but i cant seem to figure out the right way to do this. The reason i need to grab userid vs using owner, is that future other repeaters need to be looking at username so that i can filter based of that. I cant use owner to filter because that forces filter by logged in user. My current code is very basic and inserts fine but with a ‘Broken Reference’ for username. I am a novice when comes to any kind of coding. Thanks in advance for the assistance
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
let user = wixUsers.currentUser
let userID = user.id
$w.onReady( function () {
});
export function button8_click(event){
let tosave = { ‘username’ : userID}
wixData.insert( “MyMiles” ,tosave)
}