Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Expecting a string but getting an array

I want to get an array which has objects that contains string, but I am only getting the array without objects or string

const emails = [
  {
    email: "dot@gmail.com",
  },
  {
    email: "ke@gmail.com",
  },
];

const msg = {

  personalizations: emails.map((email) => ({
    to: [{ email: email.email }],
    subject: "Hello World from the Personalization API!",
  })),

};

when i console log msg I get:

{
  personalizations: [
    {
      to: [Array],
      subject: 'Hello World from the Personalization API!'
    },
    {
      to: [Array],
      subject: 'Hello World from the Personalization API!'
    }
  ],
}

I want get the values of to when I console log like this:

  "personalizations": [
    {
      "to": [
        {
          "email": "john@example.com"
        }
      ],
      "send_at": 1600188812
    },
    {
      "to": [
        {
          "email": "jane@example.com"
        }
      ],
      "send_at": 1600275471
    }
  ]
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

As from the output. It's very easy to do. I believe all you need is JSON.stringify()
So: console.log(JSON.stringify(msg));, It should do the job.
Though, for making it readable, you need JSON Prettier

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!