I'm using SweetAlert2 and on IE 11 throws exception:
This package requires a Promise library, please include a shim to enable it in this browser (See: https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2#1-ie-support)
Because IE 11 doesn't support Promises and needs to be added manually.
I'm using bluebird like so:
const Promise = require('bluebird');
const Swal = require('sweetalert2');
Swal.fire(...)
...
But still, sweetalert's check doesn't pass:
..
if (typeof Promise === 'undefined') {
error('This package requires a Promise library, please include a shim to enable it in this browser (See: https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2#1-ie-support)');
}
..
How to fix it? Thanks.
You can fix it with the following:
window.Promise = require('bluebird');
This will load Promise as a global variable of your window instead of the file like you did with the const
.
I'm not sure how your file structure is, but if you have a file that loads all the dependencies, you can simply add the line above to the script that will be called before your other scripts.
For example:
// bootstrap.js
window.Promise = require('bluebird');
window.Swal = require('sweetalert2');
// app.js
require('./bootstrap');
Swal.fire(...);