0

I have 4 object like this and i would like a new object from this data that return from rest api

let towns = [{
    id: 1,
    name: "milano"
  },
  {
    id: 2,
    name: "torino"
  },
  {
    id: 3,
    name: "bologna"
  }
];

let macro_cat = [{
    id: 1,
    name: "accommodations",
    categories: "1,2",
    structures:[]
  },
  {
    id: 2,
    name: "eatingtips",
    categories: "2,3",
    structures:[]
  },
  {
    id: 3,
    name: "services",
    categories: "5",
    structures:[]
  }
];

let category = [{
    id: 1,
    name: "hotel"
  },
  {
    id: 2,
    name: "villa"
  },
  {
    id: 3,
    name: "restaurant"
  },
  {
    id: 4,
    name: "bar"
  }
];

let structures = [{
    id: "pineta",
    name: "Pineta 1903",
    category: 3,
    town: 1,
    macro: 2,
  },
  {
    id: "masaniello",
    name: "Masaniello",
    category: 3,
    town: 2,
    macro: 2,
  },
  {
    id: "villaalbadoro",
    name: "Villa Alba doro",
    category: 3,
    town: 1,
    macro: 1
  }
];

I would like to create a new object that containt a merge of these data

{
  town: 1,
  macro: [{
id: 1
name: "accommodations"
categories: "1,2",
structures: [{
  id: "villaalbadoro",
  name: "Villa Alba doro",
  category: 3,
  town: 1,
  macro: 1
}]
  }]
str
  • 42,689
  • 17
  • 109
  • 127
  • 2
    Please learn [the difference between JSON and the Object Literal Notation](https://stackoverflow.com/questions/2904131/what-is-the-difference-between-json-and-object-literal-notation). – str Apr 08 '20 at 09:13
  • 2
    The question is not clear. Please read this: https://stackoverflow.com/help/how-to-ask . Specifically, you didn't explain the problem. "I don't know how to do something" is not a good problem description - Ideally, as explained in the link, you'd want to explain how you tried to solve the problem and what you think didn't work. – Guss Apr 08 '20 at 09:19

0 Answers0