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

Not working with Fastboot and ember-data #138

Closed
chrism opened this issue Oct 29, 2018 · 2 comments · Fixed by #143
Closed

Not working with Fastboot and ember-data #138

chrism opened this issue Oct 29, 2018 · 2 comments · Fixed by #143

Comments

@chrism
Copy link

chrism commented Oct 29, 2018

I've followed the documentation to add the initializer in fastboot/initializer/ajax.js

export default {
  name: 'ajax-service',
  initialize() {
    // noop
    // This is to override Fastboot's initializer which prevents ember-fetch from working
    // https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/fastboot/initializers/ajax.js
  }
}

and adding the AdapterFetch mixin to my adapters/application.js

import DS from 'ember-data';
import AdapterFetch from 'ember-fetch/mixins/adapter-fetch';

export default DS.JSONAPIAdapter.extend(AdapterFetch, {
});

But am still getting an error message

TypeError: Only absolute URLs are supported

Looking into this error I've seen that there is already an issue relating to it
#110

And also a PR which looks to address it
#128

But I cannot determine the correct path to resolving the issue.

In the comments of the issue there is a suggestion that this is fixed for ember-data but I don't see how to achieve this.

The PR seems out of date now due to so many subsequent commits so I tried to fork the ember-fetch repo and make the changes myself.

So I added ember-fetch-adapter as a dependency to the package.json and updating addon/mixins/adapter-fetch.js to use the adapter instead, by including the service in the mixin

  adapter: service(),

and using the adapter service in the fetch request

  _fetchRequest(url, options) {
    return this.adapter.fetch(url, options);
  },

But this now gives another error

Error: Assertion Failed: Attempting to inject an unknown injection: 'service:adapter'

I'm now at a loss as to how I can resolve this and to get ember-fetch working with ember-data and Fastboot.

I'm open to any solution, is this absolute URL issue fixable yet?

@scottkidder
Copy link

I'm running into this as well, although I haven't yet tried ember-fetch-adapter.

@scottkidder
Copy link

I can confirm #128 fixes the issue in my app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants