try this:
const data = {
"server":"S1",
"timestamp":"123456",
"data":[
{"device":"D1", "price":"50"},
{"device":"D2", "price":"60"},
{"device":"D3", "price":"70"}
]
}
result = {data: data.data.map(res=>({...res, ...{'timestamp': data.timestamp, 'server': data.server} }))}
console.log(result);
1
solved Json object with attributes + array, how to move the attributes inside the array?