Skip to content

Instantly share code, notes, and snippets.

@RossJHagan
Last active July 2, 2016 10:59
Show Gist options
  • Save RossJHagan/206f15bb2e6bc171da5296483ca0d7db to your computer and use it in GitHub Desktop.
Save RossJHagan/206f15bb2e6bc171da5296483ca0d7db to your computer and use it in GitHub Desktop.
Aurelia CLI project (0.13.6 ish) - Getting fetch client working

Steps

  1. npm i -S whatwg-fetch
  2. At top of your main file (e.g. main.ts) add import 'whatwg-fetch';
  3. If you're using typescript: typings install dt~whatwg-fetch --global (you may need a different command depending on your versions)
  4. Modify your aurelia_project/aurelia.json and put the following into the path build.bundles[1].dependencies (you'll see where all the other deps are)
          "aurelia-fetch-client",
          {
            "name": "whatwg-fetch",
            "path": "../node_modules/whatwg-fetch/fetch"
          },
  1. You'll likely get a complaint about URLSearchParams when you au run --watch. To fix, add a custom typings file at custom_typings/whatwg-fetch.extension.d.ts (name it anything *.d.ts) and add:
  interface URLSearchParams {}

Errors will still be spat out, sometimes a lot, sometimes only few, but won't break the run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment