Incorporating a new function into the handler of my ToastController button to return a promise (in this case: this.navCtrl.navigateForward()) is something I need assistance with.
This is what my code looks like:
const toast = await this.toastController.create({
header: header,
message: message,
position: 'bottom',
animated: true,
buttons: [
{
side: 'start',
text: 'Action',
handler: () => {
this.navCtrl.navigateForward('/destination');
}
}
]
});
await toast.present();
The issue arises when I receive the notification:
Promises must be handled appropriately (no-floating-promises)
I wish to make the following adjustment:
const toast = await this.toastController.create({
header: header,
message: message,
position: 'bottom',
animated: true,
buttons: [
{
side: 'start',
text: 'Action',
handler: async () => {
await this.navCtrl.navigateForward('/destination');
}
}
]
});
await toast.present();
However, an unhelpful error message pops up:
Type '{ side: string; text: string; handler: () => Promise<void>; }' is not assignable to type 'string | ToastButton'.
Type '{ side: string; text: string; handler: () => Promise<void>; }' is not assignable to type 'ToastButton'.
Types of property 'side' are incompatible.
Type 'string' is not assignable to type '"start" | "end"'.
I have been trying to solve this problem but seem to be stuck. Any guidance on where I might be going wrong would be greatly appreciated. Thank you!