JSONAPIAdapter not recognized / "findAll is not a function"

I’ve been searching high and low for a solution to this, hopefully someone here can help! Currently in my console I’m seeing this error:

In my users route I have:

import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return this.store.findAll('user');

And when I open up my Ember Inspector I see:

I’m currently using:

  • Ember CLI 2.2.0-beta.1
  • Ember 2.3.0-beta.1
  • Ember Data 2.3.0-beta.3

I have my adapter and serializer set up like so:

In adapters/application.js:

import DS from 'ember-data';

export default DS.JSONAPIAdapter.extend({

In serializers/application.js:

import DS from 'ember-data';

export default DS.JSONAPISerializer.extend({

I can’t for the life of me figure out why the adapter is not recognized… it’s got to be some minor little thing I’m somehow overlooking! Any suggestions at all are much appreciated!

You are missing a closing single-quote on your adapter and serializer DS import statements.

I’m pretty sure that is just a typo in the post that would blow up in the build phase, but I thought I’d mention it.

Does your project build correctly via ember --serve?

Yep, that was a typo in the post - fixed it just now, thanks!

And yeah, it does build correctly via ember --serve. I’m flummoxed!

Perhaps ember-data is not actually available in your app for some reason.

If you put a breakpoint in your model() method, what is the value of this.store?

@lizbaillie Could you try updating to Ember Data 2.3.0-beta.3 and ember-cli-shims 0.1.0? There was some weirdness with how the new addonized Ember Data in the 2.3 beta was interaction with the ember-cli-shims repo (which previously allowed you to import DS from 'ember-data') that resulted in the Ember Data module being an empty object.

1 Like

Just put a debugger on the line right before the findAll line, and this.store definitely populates in the console, like so:

Tried updating to Ember Data 2.3.0-beta.3 and ember-cli-shims 0.1.0, nombommed and re-npm & bower installed, no change.

In the event that there is some dependency issue I’m overlooking, here are my package.json and bower.json files:

Also tried removing ember-cli-mirage and its associated files, as I probably was not setting it up correctly and that’s caused me some grief in another project, but still the same issue persists.

Got the answer! Turns out I just needed this.get('store').findAll in my routes due to some kind of lazy injection… never would have figured out that out on my own. Thanks to @runspired on Ember Community Slack for the answer to this riddle!

ETA: Spoke too soon! The console error is gone, but still getting the ‘Data adapter not detected!’ error when I open up my Ember Inspector and click on ‘data’… :disappointed:

Any ideas welcome and appreciated!

In general, injected services do need get due to laziness. But store is supposed to be special-cased, since it’s been used like this.store since before we really had the current dependency-injection system. So if you’re finding that get is necessary, that is probably a bug.

1 Like

It appears Ember Data’s initializers are not running when it is used as an addon in the 2.3 beta. I’ve opened an pr to fix this issue in Ember Data. Run the Ember Data initializer when Ember Data is loaded as an Ember … by bmac · Pull Request #3999 · emberjs/data · GitHub

The computed property you are seeing is Ember.Route’s default store property that Ember Data’s initializers normally overrides when it injects it self into the route.

1 Like

@lizbaillie I just published Ember Data v2.3.0-beta.4. I believe it fixes this issue. Do you mind testing it out and letting me know if this error does not go away.

Thanks so much @bmac! I just updated my project, and now I’m getting this error in the console:

I didn’t change anything else in my project, just nombom’d and restarted the server. Any ideas?

@lizbaillie what version of ember-cli-shims do you have in your bower.json? If you 0.0.6 do you mind trying to update it to 0.1.0?

It is already 0.1.0 I’m afraid.

@lizbaillie I put together a test repo GitHub - bmac/test-2-3-0-beta to try and reproduce this issue.

The only thing I’ve changed is I’ve added ember-inflector to my app dependencies to satisfy Ember Data’s peer dependency. I’m hoping this won’t be necessary with the next beta.

I was unable to reproduce the issue where the ember-data/-private/setup-container module could not be loaded. Do you mind taking a look at my repo and letting me know what I’m doing differently?


@bmac took a look at the test repo and made sure my versions matched your versions, and added ember-inflector, and that seemed to do the trick! All the errors from before are gone! Huzzah! Thank you so much for all your help.

Also worth noting for others experiencing the same issue - after adding ember-inflector I was able to use return this.store.findAll('model-name') in my routes again and it worked like a charm!