i got
Error trying to diff '[object Object]'. Only arrays and iterables are allowed
this error when i'm trying to get updated data
Get code:
allDatas
allData(data) {
this.allDatas = data
}
Okay So this is Update Code i Write :
updateTodo(currentTodo){
// console.log(currentTodo)
this._todo.updateTask(currentTodo).subscribe(
data=>{console.log(data);this.allData(data)},
error=>console.log(error)
)
}
This Request Comes From Service.ts
updateTask(todo:TodoModel):Observable<TodoModel>{
return this._http.put<TodoModel>('http://127.0.0.1:3000/todo/updateTodo/'+todo.id,todo,headerOption)
}
I checked all the things using cosole.log And at the end i got the line from where i got the error let me show you
updateTodo(currentTodo){
// console.log(currentTodo)
this._todo.updateTask(currentTodo).subscribe(
data=>{console.log(data);this.allData(data)}, //Error Comes from this line----------
error=>console.log(error)
)
}
this is the same update code : when i write data=>console.log(data)
in update code then there is no longer error shows but when i use data=>{console.log(data);this.allData(data)}
i got this Error:
HTML : where i bind data:
<tbody *ngFor="let t of allDatas;let i= index">
<tr class="table-success" *ngIf="t && t.complited">
<td>{{t.task}}</td>
<td>{{t.date.year+"-"+t.date.month+"-"+t.date.day}}</td>
<td> {{t.complited}}</td>
<td>
<i class="fa fa-times-circle btn idelete" style="font-size:25px;" (click)="putTrue(t)"></i>
<i class="fa fa-edit btn iedit" style="font-size:25px;color:rgb(31, 12, 12)" (click)="editTodo(t)"></i>
<i class="fa fa-trash-o btn idelete" style="font-size:25px;" (click)="deleteTask(t.id)"></i>
</td>
</tr>
<tr class="table-danger" *ngIf="t && !t.complited">
<td>{{t.task}}</td>
<td>{{t.date.year+"-"+t.date.month+"-"+t.date.day}}</td>
<td> {{t.complited}}</td>
<td>
<i class="fa fa-check-circle btn idone" style="font-size:25px;" (click)="putTrue(t)"></i>
<i class="fa fa-edit btn iedit" style="font-size:25px;color:rgb(31, 12, 12)" (click)="editTodo(t)"></i>
<i class="fa fa-trash-o btn idelete" style="font-size:25px;" (click)="deleteTask(t.id)"></i>
</td>
</tr>
</tbody>
So allDatas is A array :
JSON Data: Where all oprations are Performed
[{"id":29,"task":"random 5","date":{"year":2020,"month":5,"day":9},"category":"genral","complited":false},null,{"id":31,"task":"task 32","date":{"year":2020,"month":5,"day":31},"category":"genral","complited":false}]
so in short i got error when i update task and getting updated task but i use the same method for post put other data i get perfect result
please someone help me i'm trying to solve this error since very long...