Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

311
Visualizações
Wix currentMember.getMember() returning undefined

I have a custom Wix profile page (made with Velo) that displays the user's information. To get that information, I have to query a database, and to query that database I have to get the currently logged in user's login email address. Fortunately, Wix has an API for that, currentMember. However, using currentMember.getMember() is returning undefined on the profile page. But after I reload the profile page, it returns an object with the correct member data (including the email I need). Why is this happening? Another thing I noticed is that I'm getting the following error in the console:

the error I'm getting

I was thinking that since the error said the URL was preloaded, perhaps the page loaded before I logged in, and thus the member object being returned is undefined, since the user hadn't logged in yet.

Here is the code I used to log the member object to the console:

import { currentMember } from 'wix-members';

$w.onReady(function () {
currentMember.getMember()
    .then((member) => {
        console.log(member);
    });
 }

And this was logging undefined, but when I reload, it gives the correct info.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I had a similar issue whereby a member logs in, but member object returned was not available until a refresh of the page occurred.

I solved this with the use of the "wix-members" onLogin() api. Below is the code I hacked together.

authentication.onLogin((memberInfo) => {
    const memberId = memberInfo.id;

    if (memberId) {
        console.log("MEMBER ID: " + memberId);
        local.setItem("auth", memberId);
    } else {
        currentMember.getMember()
            .then((member) => {
                if (member) {
                    console.log("MEMBER ID: " + member._id);
                    local.setItem("auth", member._id);
                }
                else {
                    console.log("NOT LOGGED IN!");
                }
            })
            .catch((error) => {
                console.error(error);
            });
    }
});

I had to use an if / else as the memberInfo.id property always appears undefined. I left it in the code (for my use case) in case it begins to work as expected again.

I used this in the masterPage.js onReady().

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda