Why is Promise.race([... undefined in the current version of aurelia?
You can see a good example of its use at: Error handling for fetch() in Aurelia
Why is Promise.race([... undefined in the current version of aurelia?
You can see a good example of its use at: Error handling for fetch() in Aurelia
In my aurelia-app build with aurelia-cli only Bluebird core was bundled, but Promise.race is only included in the full version.
In aurelia.json in the section "prepend", change "bluebird.core.js" to "bluebird.min.js"
"prepend": [
"node_modules/bluebird/js/browser/bluebird.min.js",
...
],
Promise.race
is supported either by the browser, or by a polyfill you supply. Aurelia does not supply a Promise polyfill. You can use Bluebird (as the skeletons do), or you can use the built-in Promises if you don't need to support older browsers. Current browser support for Promise.race
can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race
Ok, with Asheley's comment I was able to figure it out. I used bluebird as he suggested:
aurelia.json
...{
"name": "bluebird",
"path": "../node_modules/bluebird/js/browser/bluebird.min"
},...
Inside the class:
...
import {Promise} from 'bluebird';
...
Promise.race([ // is now available
...