0

i am fetching some Items from back end, now i want to create separate duplicate array ItemsModels and want to post that items into back end...can any help on this ...

getting data from backend

  const Items = [
      { uid: "01", item: "Car", carModel: "i 20", model: 2010 },
      { uid: "02", item: "Car", carModel: "i 10", model: 2009 },
      { uid: "03", item: "Car", carModel: "Swift", model: 2011 },
      { uid: "04", item: "Car", carModel: "Polo", model: 2015 }
    ];

duplicate array i want like this....

 const ItemsModels = [
      { uid: "01", carModel: "Hundai i 20" },
      { uid: "02", carModel: "Hundai i 10" },
      { uid: "03", carModel: "Swift" },
      { uid: "04", carModel: "Polo" }
    ];

1 Answer 1

1

you could do a simple map

const ItemsModels = Items.map(item => {
      const { uid, carModel } = item;
      return { uid, carModel };
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.