0👍
✅
Use map on the array:
...
[...].map((value, index) => {
return {
name: value.name,
id: index+1
}
})
...
Source:stackexchange.com