1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to map an array for an email API

Discussion in 'JavaScript' started by iago111, Jan 24, 2022.

  1. #1
    Hello I have the following Array of Objects:

    recipients:
    
    [
      {
        responded: false,
        _id: 61ef2b6dbac083198d934dfd,
         email: 'myemail1@gmail.com'
      },
       {
         responded: false,
         _id: 61ef2b6dbac083198d934dfe,
         email: 'myemail2@gmail.com'
       }
     ]
    
    Code (JavaScript):
    and I need the following result:

    
    sendSmtpEmail.to = [
    
    {"email":"myemail1@gmail.com",
      "name":"myemail1@gmail.com"},
    
    {"email":"myemail2@gmail.com", 
      "name":"myemail2@gmail.com"};
    ];
    
    
    Code (JavaScript):
    The following approach does not work:
     sendSmtpEmail.to = recipients.map((recipient) => {
          return { email: recipient.email, name: recipient.email };
        });
    Code (JavaScript):
    How can I map this correctly?

    Thanks, iago
     
    iago111, Jan 24, 2022 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #2
    sarahk, Jan 24, 2022 IP
    iago111 likes this.
  3. iago111

    iago111 Member

    Messages:
    99
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    33
    #3
    Ok, thanks @sarahk for this, probably the sendSmptEmail object is not correctly configured with that input.
    That's an email service called sendinblue
     
    iago111, Jan 24, 2022 IP