I have using a model products which has belongsTo relationship defined like this
commercePackageId: belongsTo(‘package’)
and similary for package model
products: hasMany(‘products’)
But When I am trying to access package model attribute name ,I am not able to do it
So when I do console.log(products.firstObject.commercePackageId)
The content is shwoing as null and when I print name ,it is printing as undefined
How to resolve this issue ?
Hi @Rishabh_Talwar are you customizing your adapter and/or serializer? What do your network requests look like?
My first guess is that your commercePackageId
relationship should be called commercePackage
instead, the id
gets stripped out in the serializer so it’s probably. just looking at the wrong thing, seeing undefined
and not trying to fetch the relationship at all.
I need more detail to know what the problem is I think. What is the “incorrect result”? What does the Ember model look like? How is it being fetched/rendered? What do the (fake, because mirage) network requests look like?