Trying to display the Wix FullData field "Nickname"

Question:
Why does this code not return the value in the Nickname data?

Product:
WIX custom code

What are you trying to achieve:
I have a textbox in the Header named “Logname”. When a person logs in, I want the header to display the Wix-FullData-Nickname value. It keeps returning “null”.

What have you already tried:
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import { local } from ‘wix-storage-frontend’;

$w.onReady(function () {

const user = wixUsers.currentUser;
const loggedIn = user.loggedIn;

if (loggedIn) {

    wixData.query("Members/FullData")
        .find()
        .then((results) => {

            if (results.items[0].nickname === null) {

                // On first page set a Local Data item for their Nickname
                local.setItem("Logname", results.items[0].nickname);
                local.setItem("JungleXP", 0);

            } else {

                local.setItem("Logname", "Adventurer");
                local.setItem("JungleXP", " ");

            }

            // Now display it in the header
            // $w('#namebox').text = "Welcome " + local.getItem("Logname") + "??";
            $w('#namebox').text = "Welcome " + local.getItem("Logname");
            $w('#XPbox').text = "XP: " + local.getItem("JungleXP");

        })

} else {
    $w('#namebox').text = "Please Log In.";
    $w('#XPbox').text = " ";
    $w("#btnJungleStart").disable()
        .then(() => {
            $w("#btnJungleStart").label = "Locked - Log In";
        });
}

});

Wix-users is deprecated. Try using wix-members-fronted instead.

Hi!!

I’m on mobile so can’t write out my code suggestion, but I BELIEVE with Members/FullData, there’s an underscore before the item call (I know, makes no sense). It’ll show red in the velo IDE, but try a couple console.logs to confirm:

console.log(results)
console.log(results._items[0])

Hello again, @Dale_Hans

Checked my own code, and it’s for sure an underscore missing before ‘items’ when using Members/FullData. Try:

results._items[0].nickname

Cheers,
Jess

I will like to know if you still need help, so that I can help you to fix the modification for your Wix website