open-nomad/ui/app/utils/fetch.js
Michael Lange d455b3cdd3 mirageEnabled alone doesn't capture whether or not mirage is enabled
Add an isProduction condition to ensure native fetch is used when
possible.
2018-03-21 22:09:10 -07:00

15 lines
466 B
JavaScript

import Ember from 'ember';
import fetch from 'fetch';
import config from '../config/environment';
// The ember-fetch polyfill does not provide streaming
// Additionally, Mirage/Pretender does not support fetch
const mirageEnabled =
config.environment !== 'production' &&
config['ember-cli-mirage'] &&
config['ember-cli-mirage'].enabled !== false;
const fetchToUse = Ember.testing || mirageEnabled ? fetch : window.fetch || fetch;
export default fetchToUse;