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' ]
};
currentMember.getMember(options)
.then((member) => {
//const id = member._id;
//const fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
return member;
})
.catch((error) => {
console.error(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