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

123
Visualizações
Getting undefined in the array of strings

I have the following Javascript code:-

    const mainFunction = async (message) => {
      const templateData = {};
      templateData.name = message.firstName;
      templateData.email = message.emailAddress;  
      templateData.account = message.accountType;
      console.log("message::::", message);
      const userId = message.userId;
    
      const emailAddresses = [`${message.emailAddress}`];
      console.log("emailAddresses->", emailAddresses);
}

Logs:-

2022-03-10T14:33:50.807+05:30

Copy
2022-03-10T09:03:50.806Z    8681ec6b-7f57-5148-bdd3-b6c8be7d2f15    INFO    message:::: 
{
    "userId": "b4c6cab0-a944-5f5e-81cd-b1dad4c0b54a",
    "emailAddress": "tom.dick9000@gmail.com",
    "notificationType": "NEW_USER_WELCOME_MESSAGE",
    "firstName": "tom",
    "lastName": "dick",
    "accountType": "BASIC"
}

2022-03-10T09:03:50.806Z 8681ec6b-7f57-5148-bdd3-b6c8be7d2f15 INFO message:::: {"userId":"b4c6cab0-a944-5f5e-81cd-b1dad4c0b54a","emailAddress":"tom.dick9000@gmail.com","notificationType":"NEW_USER_WELCOME_MESSAGE","firstName":"tom","lastName":"dick","accountType":"BASIC"}

2022-03-10T14:33:50.807+05:30   2022-03-10T09:03:50.807Z 8681ec6b-7f57-5148-bdd3-b6c8be7d2f15 INFO emailAddresses-> [ 'undefined' ]

The problem is the constant emailAddress is coming as undefined but the value of the emailAddress attribute is present in the object message. I want to pass the dynamic value to this array of Strings but not working at all.

Please let me know why it is coming as undefined. Thanks

about 4 years ago · Juan Pablo Isaza
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