I have an array of object like this,
let array1 = [{id:1,name:'One'}]
whenever i do api call, the array of objects getting updated like this
let array2 = [{id:1,name:'One'}, {id:2, name:'Two'}]
for third time, it will be like this,
let array3 = [{id:1,name:'One'}, {id:2, name:'Two'}, {id:3, name: 'Three'}]
Now am trying to add key value pair for every object inside the array as
obj = {
key: 'value'
}
[...array1, obj]
am getting an output like [{id:1,name:'One'},{key: 'value'}]
but the expected output is [{id:1,name:'One',key: 'value'}]
that object should be pushed into an array after every api call