Using fetch()
without importing it causes the browser to use the native,
non-wrapped window.fetch()
. This is generally fine, but makes testing harder
because this non-wrapped version does not have a built-in test waiter. Because
of this it is generally better to use ember-fetch and explicitly
import fetch from 'fetch'
.
The rule looks for fetch()
calls and reports them as issues if no
corresponding import declaration is found.
Examples of incorrect code for this rule:
const result = fetch('/something');
Examples of correct code for this rule:
import fetch from 'fetch';
const result = fetch('/something');
- Add
import fetch from 'fetch';
to all files that need it
- @ember/test-waiters addon