Assign Badges sending a notification on every page visit; help!

@amandam Ok, I hesitate to say this again… but I got it!!! Using the console log to show results from the query was the key. The issue was that I had to define the loggedInMember._id as a variable, and use that variable in the query.


import { currentMember } from ‘wix-members’ ;
import { getMemberBadges , getVirtuosoBadge } from ‘backend/getBadges’
import wixData from ‘wix-data’

const options = {
fieldsets : [ ‘FULL’ ]
}

$w . onReady ( async function () {

$w ( '#myBadges' ). data  = [] 

**const**  loggedInMember  =  **await**  currentMember . getMember ( options ); 

**const**  memberBadges  =  **await**  getMemberBadges ( loggedInMember . _id ); 
**const**  currentMemberID  =  loggedInMember . _id 
**if**  ( memberBadges ) { 
    myBadges ( memberBadges ) 
} 

wixData . query ( "Forum/Posts" ) 
    . eq ( "_ownerId" ,  currentMemberID ) 
    . gt ( "likeCount" ,  10 ) 
    . find () 
    . then (( results ) => { 
        console . log ( results . items ); 
        **if**  ( results . items . length  >  0 ) 
            getVirtuosoBadge ( loggedInMember . _id ); 

    }); 

Again… THANK YOU so much! I have learned a tremendous amount of coding from this tricky little excercise and I can use these new skills for so many things. Please feel free to send me your supervisor’s email so I can tell them how helpful and professional you were and are!