How to handle Error when pushing data with angularFire2?
I used the following method:
todoLists: AngularFireList<TodoList>;
addList(data): ThenableReference {
const item: Item = {
name: data.task,
state: false,
description: 'No description'
};
const todoList: TodoList = {
id: '',
name: data.name,
items: [item]
};
this.todoLists.push(todoList).then(_ => this.presentToast('List succesfuly added'))
.catch(err => _ => this.presentToast('Something wrong happened'));
}
The problem here is that the push method of AngularFire
returns an ThenableReference
so the catch method doesn't exist in that interface.
Here's the message from the editor (vscode)
property catch doesn't exist on type promiseLike<> There must another way to handle errors.