How do I retrieve a current member's ID?

I’m having an issue with retrieving a logged in member’s ID. I’m using the backend function:

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

export function myGetCurrentMemberFunction ( ) {
return currentMember . getMember ()
. then (( member ) => {
return member . _id ;
})
. catch (( error ) => {
return error ;
})
}

If I run it from the backend, it fetches the member’s ID correctly. When I call this function from the front end of my published site and the currently logged in member is the owner, it runs correctly. If the owner logs out and someone else logs in, it doesn’t return anything and the rest of the page just doesn’t load. What am I doing wrong?