Getting error on profile page!

Error:
Loading the code for the My Profile page.
To debug this code, open vq4en.js in Developer Tools.
An error occurred in one of datasetReady callbacks TypeError:
Cannot read property ‘firstName’ of null

was also getting this error:
Failed to load initial data Error: WDE0028: Request timed out.

Any Ideas? Is it a problem with the database?

Here is the code
Code:
import wixData from ‘wix-data’;

let user;

$w.onReady( function () {
//handler for getting the user information once the dataset is ready
$w(“#updateProfile”).onReady( async function () {
//first grab the user from the dataset
user = $w(“#updateProfile”).getCurrentItem();

//now get the name of the user
$w(“#firstName”).value = user.firstName;

//Check if user exits. If user does not exist, user === null
if (user) {
//user exists, show updateProfileButton and welcome user.
$w(“#updateProfileButton”).show();
$w(“#welcomeUser”).text = Welcome ${user.firstName};
$w(“#profileArea”).expand();

//call getReferralCount which returns a number of referalls for current user.
var count = await getReferralCount(user.referralCode)
$w(“#numRef”).text = count.toString();
} else {
//user does not exist, ask them to create their profile.
$w(“#createProfileButton”).show();
$w(“#updateProfileButton”).hide();
$w(“#profileArea”).collapse();
$w(“#welcomeUser”).text = Welcome New User. Please create a profile!;
}
});

//handler for after the dataset has been updated/saved with new info
$w(“#updateProfile”).onAfterSave(() => {
//get the name of the user and prompt update
$w(“#welcomeUser”).text = “Update Completed!”;

//here we are delaying it by 2500 milliseconds (2.5 seconds) before prompting the welcome
const millisecondsToDelay = 2500;
setTimeout(() => {
$w(“#welcomeUser”).text = Welcome ${user.firstName};
}, millisecondsToDelay);
});

//countdown
var countDownDate = new Date().getTime();
//$w(“#countDownTimer”).text = hours + "72 " + minutes + "m " + seconds + "s ";
});

/**

  • getReferralCount(referralCode) returns the total number of times the user’s referralCode appears in the
  • profile database.
    */
    export async function getReferralCount(referralCode) {
    //first lets find it.
    let query = await wixData.query(“profile”).eq(“referredBy”, referralCode).find();

//return the count
return (query.items.length);
}

It means the results do not contain a field key called firstName. Console log user results to see what field keys available from the current item results.

console.log(user);

Its actually a wix error!

https://support.wix.com/en/article/29-august-2019-editing-database-feature-temporarily-not-available

Your code looks remarkably similar to Nayeli’s (Code Queen) code from her tutorial here.
https://codequeen.wixsite.com/membership-dashboard

If you are taking her code example and modifying it to suit your own needs, then I would suggest that you contact her directly if you have any issues with it. Then if she can’t help you, then please come back to this forum and ask for more help and someone will try to help you.

As for your error link, well that is now fixed according to Wix, so in theory you shouldn’t have the error still persisting with your website. However, if you do then please follow Mike’s prefect response and check that your firstName field does actually contain a value that the code can use.

@code-queen

I had to delete the fields in data base and re add. Problem solved