0

Data which I am getting from backend is in array object format how can I convert that a particular data format for example:

data = [
  { name: value, age: value, phoneNumber: value, email: value },
  { name: value, age: value, phoneNumber: value, email: value },
  { name: value, age: value, phoneNumber: value, email: value },
]

I want that data into this format for example:

data = {
  person: [
    { name: value, email: value },
    { name: value, email: value },
    { name: value, email: value },
  ],
}

1 Answer 1

1

You could achieve this with map

data = {
  person: data.map(({ name, email }) => ({ email, name })),
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.