Getting user ID

I’m new to this stuff, though not to programming in general, and have looked at lots of examples and forum posts. Somehow, my efforts at getting the user ID in code have drawn a blank. It’s probably something stupid! Can anyone help, please? Here is how it looks, spookily similar to some of the examples out there …

import wixUsers from ‘wix-users’ ;

$w.onReady( function () {

let strUserId = wixUsers. currentUser. id; //(spaces inserted here so it isn’t a “link”
$w( ‘#txtTest1’ ).text = strUserId;

The referenced text box remains stubbornly blank.

Using your code - It works fine for me. Please provide more information.

Well, that’s weird. I decided that it must be something else on the page or in the code that was causing trouble, so I started again with a blank page and no code. After building the code and the page up again step by step, everything worked. There must have been something bad lurking in the background, though I have no idea where.

Thank you for your help, Yisrael.

Hmmm, “something bad lurking in the background” - sounds like a tagline for a new thriller series.

Glad I could help. I really like these easy ones.

Perhaps the long-awaited sequel… Lucifer: Javascript Programmer