Page 1 of 1

Ionic 4 - How to dIsplay error result in alert

Posted: Fri Sep 11, 2020 9:51 pm
by Peter Westcott

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 1147 times

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

Posted: Wed Sep 16, 2020 12:30 pm
by Serhii Kulibaba

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();
        })();