How to Get Slug or Nickname from Member Data

I’ve been trying to do this for weeks :P.
From what I understand, I can access the Member Data from both the front and back end. My goal is to get the Slug or Nickname of a Member based on their Member ID.
From the Front-End, these are required for authentication:

import { authentication } from 'wix-members'; 
import { currentMember } from 'wix-members'; 

Here is the function for retrieving the data (this retrieves the data of the current member logged in):

let options = {
   fieldsets: [ 'PUBLIC' ]

  .then((member) => {
    //const id = member._id;
    //const fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
    return member; 
  .catch((error) => {

But I get this error, which hints at an authentication error.

Error: Ambassador client request failed: HTTP STATUS: -1 RESPONSE: "Failed to fetch" See the httpStatus and response fields for more information.

I tried to do this from the back-end code too, but Promises don’t agree too much from being imported from the back-end (which always results in the return being “Promise object”; perhaps I am doing it wrong), so that’s why I am attempting to do it from the front end.

Someone please help, I’ve been failing at this for a long time and I’ve gotten every other Promise/Function from the API to work except this one. I literally copy and pasted the APIcode and it still doesn’t work.
Thank you and God Bless :slight_smile:

Tbh, I don’t think there has been a single person who has gotten this to work.

Tbh, I don’t think there has been a single person who has gotten this to work.

!!! Wrong opinion !!! :wink:

You even do not need much…

import wixData from 'wix-data';

$w.onReady(function() {

And your second part would be → just to get the ID of the current logged-in user.

Good luck and happy coding.

Hi Chance, I totally agree with you, it’s PAAAAAIN!! Were you able to get it to work? I’ve been trying every workaround I can think of. I will surely let you know if I finally figure it out.

I was FINALLY able to access and use to all of the above on the backend! The key was cleaning up all my promises. For more info on how best to use member data on the backend, this article that hackernoon posted on velo promises was absolutely GOLDEN!!

Thank you @hackernoon!

1 Like

tried this but getting all fields values as null.

Where is your code?

You better open your own post, instead of bumping up old ones.
You can link this one to your own post.
Describe your issue in detail and provide your code.