Persistant Wix-Authentication / Wix-Members-API issue

I’m fairly new to the Velo APIs and am probably missing something obvious, but I’m still having the same issue mentioned above. I’m using a backend script, and the users must already be logged in to access the page.

Below is the function in the backend file:


/*********
backend.jsw file


import { currentMember } from ‘wix-members-backend’ ;

export function myBackendFunction ( ){

**return**  currentMember . getMember ({ fieldsets : [ 'FULL' ]}) 
. then (( member ) => { 
     **const**  fullName  =  ` ${ member . contactDetails . firstName } ${ member . contactDetails . lastName }`; 
     console . log ( fullName ) // print to console 
     **const**  userID  =  member . _id ; 
    **return**  member ; 
}) 

}


This should print the user’s name to the console, but when called in the user side, it still outputs the user as undefined. The page is members only, so there’s no chance of the user not being logged in.

I’ve tried implementing the same code without the backend file, and run into the same problem. Does anyone have a suggestion/fix?