1

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

Community
  • 1
  • 1

3 Answers3

3

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",
      ...
    ],
1

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

Ashley Grant
  • 10,879
  • 24
  • 36
  • Hmmm I use Firefox 48.0.1 and Safari 9.1.2 which are supposed to support Promise.race but I still get the error: Inner Error: Message: Promise.race is not a function I will look into Bluebird. –  Aug 24 '16 at 17:13
1

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
...