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

155
Views
Adding a prefix to the key of an object in axios

I have the object

data = {
    others: [
        {
            code: "A", label: "0-A"
        },
        {
            code: "B", label: "0-B"
        },
        ...,
        {
            code: "N", label: "0-N"
        }
    ]
}

And I need to add the other_ prefix to code value(example, other_N) before sending it to the axios query:

await axios.post(`${URL}`, { data })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Something like this

let data = {
  others: [{
      code: "A",
      label: "0-A"
    },
    {
      code: "B",
      label: "0-B"
    },
    {
      code: "N",
      label: "0-N"
    }
  ]
};

let modifiedData = data.others.map(x => {
  x.code = `other_${x.code}`;
  return x;
})

console.log(modifiedData);

about 4 years ago · Juan Pablo Isaza Report

0

you can use the Array.map function to manipulate the data object

data.others.map(x => { return { other_code: x.code, label: x.label }})
about 4 years ago · Juan Pablo Isaza 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!