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

172
Views
Why am I getting an error in JSON object?
 res.send({
          customerDetails:{
            fName,
            lName,
          },
          applicantDetails:{
            [
              {primaryApplicant:{fName1,lName1}},
              {secondaryApplicant:{fName2,lName2}},
              {thirdApplicant:{fName3,lName3}}
            ]
          }
        })
        

I am getting an error saying " ':' expected " when I hover over the 2nd last '}' bracket. How to send the above response?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

applicantDetails is an array and you are using object.

let fName = "fName", lName = "lName", fName1 = "fName1", lName1 = "lName1", fName2 = "fName2", lName2="lName2", fName3="fName3", lName3="lName3";
var obj = {
          customerDetails:{
            fName,
            lName,
          },
          applicantDetails:
            [
              {primaryApplicant:{fName1,lName1}},
              {secondaryApplicant:{fName2,lName2}},
              {thirdApplicant:{fName3,lName3}}
            ]
          
}
console.log(obj)
    

about 4 years ago · Santiago Trujillo Report

0

Your formatting is wrong, you probably want applicantDetails to be an array instead of an object.

const res = {
  customerDetails: {
    fName,
    lName,
  },
  applicantDetails: [{
      primaryApplicant: {
        fName1,
        lName1
      }
    },
    {
      secondaryApplicant: {
        fName2,
        lName2
      }
    },
    {
      thirdApplicant: {
        fName3,
        lName3
      }
    }
  ]
}
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!