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

Wiered error. data.data is undefined #3377

Closed
novtor opened this issue Jun 18, 2015 · 10 comments
Closed

Wiered error. data.data is undefined #3377

novtor opened this issue Jun 18, 2015 · 10 comments

Comments

@novtor
Copy link

novtor commented Jun 18, 2015

Hello,
I have a wiered error with ember-data 1.13.1
ember-data.js, line 12671: data.data is undefined, the line in question is:

modelName = data.data.type;

It happens when I call
store.findRecord('record1', id);

my record1 has 3 hasMany relations that are side loaded in the same response. I am using RESTAdapter

@wecc
Copy link
Contributor

wecc commented Jun 18, 2015

Are you pushing JSON-API data to store.push() manually? Have you opted in to the new Serializer API?

@novtor novtor changed the title Has many sync relationship is not initialized in afterModel hook Wiered error. data.data is undefined Jun 18, 2015
@novtor
Copy link
Author

novtor commented Jun 18, 2015

@wecc, no I do not push data manually. And for the new Serializer API I have not yet seen the documentation. Tried to create a jsbin to reproduce but in jsbin everything works fine. Here is my approximate usecase
http://emberjs.jsbin.com/dideza/edit?html,js,output

@wecc
Copy link
Contributor

wecc commented Jun 18, 2015

@novtor I think we've tracked down the issue, @bmac is working on it. Thanks for reporting!

@novtor
Copy link
Author

novtor commented Jun 18, 2015

thank you @wecc

@novtor
Copy link
Author

novtor commented Jun 18, 2015

I have modified jsbin
http://emberjs.jsbin.com/dideza/edit?html,js,output
Now it throws an error not the same as I had but similar at the same line:
ember-data/ember-data.js:12675:11
Cannot read property 'type' of undefined TypeError: Cannot read property 'type' of undefined
In this jsbin ember-data v1.13.0 (could not find 1.13.1 on net, link on emberjs.com yeilds 404)

@bmac
Copy link
Member

bmac commented Jun 18, 2015

@wecc I tested @novtor's jsbin with #3379 and it helps the situation but it seems there is another error now where undefined is getting added to the includes array. I'm still investigating.

@bmac
Copy link
Member

bmac commented Jun 18, 2015

I figured it out. AdressSerializer needs to opt into the new serializer api.

We should likely assert for that case and give a better warning.

App.AdressSerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
    isNewSerializerAPI: true,
    attrs: {
        gorods: { embedded: 'always' }
    }
});

@novtor
Copy link
Author

novtor commented Jun 19, 2015

Thank you @bmac, that's do the deal. I'd been setting isNewSerializerAPI on my rest adapter not on rest serializers, my error, thank you for your help

@jcope2013
Copy link
Contributor

ran into this also #3379 fixed my problem

@bmac
Copy link
Member

bmac commented Jun 19, 2015

I just published ember-data 1.13.3 with a fix for this bug.

@bmac bmac closed this as completed Jun 19, 2015
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

No branches or pull requests

4 participants