Cannot read matching property 'w90> in Ember.DefaultResolver.extend.podBasedComponentsInSubdir

I get a very opaque error message (opaque in the sense that I donโ€™t have a link for my own source) from the console, Iโ€™m not quite sure where to look, I feel that this is more of an error in the library code, but before posting it to github I just double-check it not for my own mistake.

Problem

The problem is simple, I call this.store.find('player') , hoping to get a list of all the players and then display them in some list, but I donโ€™t even go past the download part. The data is retrieved from the server and looks properly formatted, but after calling the route.model method, something like a failure occurs. And the error message seems to be located somewhere in the code of the ember.js library, and does not indicate anything to my own code.

Server response

The content type, of course, is application/json , and note that the id property is actually _id .

 [ { "_id":"55405a5102b4ed623c225e87", "alias":"mikeTest", "__v":0, "scans":[], "createdAt":"2015-04-29T04:13:05.223Z" } ] 

Error message

Please note that there is a part of the stack trace pointing to my source, only Ember source. Which made this a pain for debugging.

 Error while processing route: leader Cannot read property 'match' of undefined TypeError: Cannot read property 'match' of undefined at Ember.DefaultResolver.extend.podBasedComponentsInSubdir (http://localhost:4200/assets/vendor.js:60138:76) at http://localhost:4200/assets/vendor.js:60190:34 at Array.exports.default.mixin.Mixin.create.find (http://localhost:4200/assets/vendor.js:39572:30) at Ember.DefaultResolver.extend.findModuleName (http://localhost:4200/assets/vendor.js:60188:44) at resolveOther (http://localhost:4200/assets/vendor.js:60051:37) at superWrapper (http://localhost:4200/assets/vendor.js:28141:20) at exports.default.EmberObject.default.extend.resolve (http://localhost:4200/assets/vendor.js:15454:35) at Object.resolve [as resolver] (http://localhost:4200/assets/vendor.js:15217:23) at resolve (http://localhost:4200/assets/vendor.js:12792:29) at Object.Registry.resolve (http://localhost:4200/assets/vendor.js:12336:21) 

A source

This ember application is very young, so at the moment the source is very small, but at the moment it is all the relevant source.

Routes

 import Ember from 'ember'; import config from './config/environment'; var Router = Ember.Router.extend({ location: config.locationType }); export default Router.map(function() { this.resource('leader'); this.resource('profile'); this.route('loading'); }); 

Leadership route

The leader has a template and controller, but they are currently empty.

 import Ember from 'ember'; export default Ember.Route.extend({ model: function () { return Ember.RSVP.hash({ players: this.get('store').find('player') }); }, }); 

Player model

 import DS from 'ember-data'; export default DS.Model.extend({ alias: DS.attr('string'), createdAt: DS.attr('date'), scans: DS.hasMany('scan'), }); 

Application adapter

 import DS from 'ember-data'; export default DS.RESTAdapter.extend({ namespace: '' }); 

Application Serial Number

 import DS from 'ember-data'; export default DS.RESTSerializer.extend({ primaryKey: function (type) { return '_id'; }, serializeId: function(id) { return id.toString(); } }); 

Version

I'm not sure if any of the versions are particularly important here.

  • ember-cli 0.2.3
  • ember-data 1.0.0-beta.16.1
  • Ember 1.11.1

Things i tried

  • removing properties from the model, in case the relationship seemed to be a problem (nothing has changed)
  • I tried to configure the serializer and adapter for the application (see above), nothing has changed.
    • serializer in case the id field in the response is actually _id .
  • tried to update ember data, nothing has changed.
+5
source share
1 answer

Ok, I realized what is being done wrong ... I forgot to check if the data returned by the server matches the protocol / protocol required to use ember data. JSON returned by the server is as follows.

 [ { "_id":"55405a5102b4ed623c225e87", "alias":"mikeTest", "__v":0, "scans":[], "createdAt":"2015-04-29T04:13:05.223Z" } ] 

In fact, it should look like this:

 { "players": [ { "_id":"55405a5102b4ed623c225e87", "alias":"mikeTest", "__v":0, "scans":[], "createdAt":"2015-04-29T04:13:05.223Z" } ] } 

So yes, I was stupid and something was missing.

Why is it necessary

Ember data expects JSON to return from the server to meet the JSON API Standard , which is the standard that defines the formatting of the JSON returned from the server. In this case, the data did not comply with the JSON API standard, since I forgot to put an array of players under the key called players . There are several more examples of this in the Ember v1.10.0 model guide.

The reason Ember Data expects this to be so, Ember Data can make certain assumptions about the data returned from the server.

+7
source

All Articles