JSONAPIAdapter not recognized / "findAll is not a function"


#1

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!


#2

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?


#3

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!


#4

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?


#5

@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.


#6

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.


#7

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!


#8

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.


#9

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. https://github.com/emberjs/data/pull/3999

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.


#10

@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.


#11

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?


#13

@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?


#14

It is already 0.1.0 I’m afraid.


#15

@lizbaillie I put together a test repo https://github.com/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?

Thanks


#16

@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!