Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename import path to 'ember-fetch' #737

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ember-fetch requries ember-cli 2.13 or above.

```js
import Route from '@ember/routing/route';
import fetch from 'fetch';
import fetch from 'ember-fetch';

export default Route.extend({
model() {
Expand All @@ -34,22 +34,7 @@ export default Route.extend({

Available imports:
```js
import fetch, { Headers, Request, Response, AbortController } from 'fetch';
```

### Use with TypeScript
To use `ember-fetch` with TypeScript or enable editor's type support, You can add `"fetch": ["node_modules/ember-fetch"]` to your `tsconfig.json`.

```json
{
"compilerOptions": {
"paths": {
"fetch": [
"node_modules/ember-fetch"
]
}
}
}
import fetch, { Headers, Request, Response, AbortController } from 'ember-fetch';
```

### Use with Ember Data
Expand Down Expand Up @@ -126,7 +111,7 @@ otherwise you can read the status code to determine the bad response type.

```js
import Route from '@ember/routing/route';
import fetch from 'fetch';
import fetch from 'ember-fetch';
import {
isAbortError,
isServerErrorResponse,
Expand Down
2 changes: 1 addition & 1 deletion fastboot/instance-initializers/setup-fetch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setupFastboot } from 'fetch';
import { setupFastboot } from 'ember-fetch';

/**
* To allow relative URLs for Fastboot mode, we need the per request information
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ module.exports = {
_getModuleHeader({ hasEmberSourceModules, nativePromise }) {
if (hasEmberSourceModules && nativePromise) {
return `
define('fetch', ['exports', 'ember'], function(exports, Ember__module) {
define('ember-fetch', ['exports', 'ember'], function(exports, Ember__module) {
'use strict';
var Ember = 'default' in Ember__module ? Ember__module['default'] : Ember__module;`;
}

if (hasEmberSourceModules) {
return `
define('fetch', ['exports', 'ember', 'rsvp'], function(exports, Ember__module, RSVP__module) {
define('ember-fetch', ['exports', 'ember', 'rsvp'], function(exports, Ember__module, RSVP__module) {
'use strict';
var Ember = 'default' in Ember__module ? Ember__module['default'] : Ember__module;
var RSVP = 'default' in RSVP__module ? RSVP__module['default'] : RSVP__module;
Expand All @@ -254,13 +254,13 @@ define('fetch', ['exports', 'ember', 'rsvp'], function(exports, Ember__module, R

if (nativePromise) {
return `
define('fetch', ['exports'], function(exports) {
define('ember-fetch', ['exports'], function(exports) {
'use strict';
var Ember = originalGlobal.Ember;`;
}

return `
define('fetch', ['exports'], function(exports) {
define('ember-fetch', ['exports'], function(exports) {
'use strict';
var Ember = originalGlobal.Ember;
var Promise = Ember.RSVP.Promise;`;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/dummy/app/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Route from '@ember/routing/route';
import { hash } from 'rsvp';
import fetch, { Request } from 'fetch';
import fetch, { Request } from 'ember-fetch';
import ajax from 'ember-fetch/ajax';

export default Route.extend({
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/error-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { module, test } from 'qunit';
import Pretender from 'pretender';
import fetch, { AbortController } from 'fetch';
import fetch, { AbortController } from 'ember-fetch';
import {
isUnauthorizedResponse,
isForbiddenResponse,
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/root-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { visit, click, find, currentRouteName } from '@ember/test-helpers';
import Pretender from 'pretender';
import fetch from 'fetch';
import fetch from 'ember-fetch';

var server;

Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Controller from '@ember/controller';
import { run } from '@ember/runloop';
import fetch from 'fetch';
import fetch from 'ember-fetch';

export default Controller.extend({
actions: {
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Route from '@ember/routing/route';
import { hash } from 'rsvp';
import fetch from 'fetch';
import fetch from 'ember-fetch';

export default Route.extend({
model: function() {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/abortcontroller-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from 'qunit';
import { AbortController } from 'fetch';
import { AbortController } from 'ember-fetch';

module('AbortController', function() {
test('signal', function(assert) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/error-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from 'qunit';
import { Response } from 'fetch';
import { Response } from 'ember-fetch';

import {
isUnauthorizedResponse,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/headers-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from 'qunit';
import { Headers } from 'fetch';
import { Headers } from 'ember-fetch';

module('Headers', function() {
test('iterator', function(assert) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utils/determine-body-promise-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from 'qunit';
import { Response } from 'fetch';
import { Response } from 'ember-fetch';
import determineBodyPromise from 'ember-fetch/utils/determine-body-promise';

module('Unit | determineBodyPromise', function() {
Expand Down