Peter Westcott
Posts: 1
Joined: Wed Sep 30, 2015 8:37 pm

Ionic 4 - How to dIsplay error result in alert

Hello

How can I use the result of the error on the message text of the alert?

screenshot-appery.io-2020.09.11-23_46_47.png
screenshot-appery.io-2020.09.11-23_46_47.png (68.66 KiB) Viewed 1127 times
Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Re: Ionic 4 - How to dIsplay error result in alert

Hello,

Please use a custom TypeScript there. Only there the error variable is available, so you can use it to display its value in the alert, e.g.:

Code: Select all

await (async () => {
            let options = {
                'header': 'Error',
                'message': JSON.stringify(err),
                'subHeader': '',
                'buttons': [{
                    'text': 'OK',
                }]
            }
            let controller = this.Apperyio.getController('AlertController');
            const alert = await controller.create(options);
            return await alert.present();
        })();

Return to “Issues”