angular-crash-todolist
angular-crash-todolist copied to clipboard
deleting one new todo -> deletes all new todos
Form submit doesn't generate todo.id, resulting in delete one new todo -> deletes all new todos. Can you please update the code?
Form submit doesn't generate todo.id, resulting in delete one new todo -> deletes all new todos. Can you please update the code?
The id property will always be 201. This is just a test API and so in the real world, the database would auto-increment the value of the id. The deleteTodo function in the todo.service.ts targets the id property only.
deleteTodo(todo: Todo): Observable<Todo> {
const url = ${this.todosUrl}/${todo.id}
;
return this.http.delete<Todo>(url, httpOptions);
}
https://jsonplaceholder.typicode.com/guide.html
This helps, thank you.