mardi 18 août 2015

Getting Uncaught TypeError "some object" is not a function in basic find request

I'm using EmberData with an Express backend which is connected to MongoDB with Mongoose.

I have a route file at app/routes/commands/index.js which has a model hook like so

model: function() {return this.store.find('command');}

The template at app/templates/commands/index.hbs looks like this

{{#each command in model}}
<p>Trigger: {{trigger}}</p>
<p>Response: {{response}}</p>
<p>Permission: {{permission}}</p>
{{/each}}

In the console I see this error on the /commands page

Uncaught TypeError: this.record.trigger.apply is not a function
ember$data$lib$system$model$internal$model$$InternalModel._triggerDeferredTriggers @ internal-model.js:439
Queue.invoke @ ember.debug.js:910
Queue.flush @ ember.debug.js:974
DeferredActionQueues.flush @ ember.debug.js:770
Backburner.end @ ember.debug.js:160
Backburner.run @ ember.debug.js:228
run @ ember.debug.js:20075
ember$data$lib$system$adapter$$default.extend.ajax.Ember.RSVP.Promise.hash.success @ rest-adapter.js:831
jQuery.Callbacks.fire @ jquery.js:3148
jQuery.Callbacks.self.fireWith @ jquery.js:3260
done @ jquery.js:9314
jQuery.ajaxTransport.send.callback @ jquery.js:9718

I've not seen this error before so I'm getting a little thrown off. When I look in the ember inspector in the data tab I see the commands that the express server is sending back so the connection is working and returning results just fine.




Aucun commentaire:

Enregistrer un commentaire