I am trying to pass the res[i].id value to my ArrayList while maintaining the sequence. Can anyone help me understand why 809 and 806 are not getting added to the arrayList correctly?
0: {id: 0, ArrayListID: 809, VarName: "TEST001A"}
1: {id: 0, ArrayListID: 806, VarName: "TEST002A"}
2: {id: 0, ArrayListID: 0, VarName: "TEST001B"} //desired result
3: {id: 0, ArrayListID: 0, VarName: "TEST002B"}
809
809 // res[i].id goes here
806
806
varName:any[] = [];
postTesting(){
this.serv.postTest(this.fg.value?.dRay).subscribe((res:any[])=>{
console.log(res)
for(var i = 0; i < res.length; i++){
this.varName[i].ArrayListID = res[i].id
}
this.serv.postTest1(this.varName).subscribe((r)=> {
console.log()
})
})
}