import wixLoyalty from 'wix-loyalty.v2';
import wixUsers from 'wix-users';
$w.onReady(async function () {
const user = wixUsers.currentUser;
if (user.loggedIn) {
try {
// Get the current user's loyalty account
const account = await wixLoyalty.accounts.getAccount(user.id);
// Display the user's loyalty points
$w('#pointsText').text = `You have ${account.points} loyalty points.`;
} catch (error) {
// Handle errors such as invalid GUIDs or API issues
console.error('Error retrieving loyalty points:', error);
$w('#pointsText').text = "Error retrieving your loyalty points.";
}
} else {
$w('#pointsText').text = "Please log in to see your loyalty points.";
}
});
Would be helpful if you provided what’s wrong, and not just your code