@johnnyicon wrote:
Hi all,
I’ve been struggling to figure out why I can’t access a related model and its properties in a template. The relationship is very simple:
- User belongsTo Organization
- Organization hasMany Users
I’m working with a
userrecord, and I’m trying to display the user’s organization’s name via theuserrecord (e.g.,user.organization.name). For a little more context, the API call uses theincludedirective, and the JSON response returns a JSON API Spec compliant response for this call.Using the console, when I try to access the organization via the user, a Proxy object is returned.
user.organizationreturns
Proxy {_belongsToState: BelongsToRelationship, isFulfilled: true, isRejected: false, content: Class, _super: ƒ}So in order to access the organization’s name, I have to do the following:
user.organization.then((org)=>{console.log(org.name)});returns
Awesome Co Promise {_id: 240, _label: undefined, _state: 1, _result: undefined, _subscribers: Array(0)}This works just fine. It prints out the organization’s name, and then it returns a Promise object.
Side question: is this supposed to happen?
Now, when I try to access the organization’s name in a template (as shown below), nothing is displayed in the template.
{{#if user.organization.isPending }} Loading... {{ else }} {{ user.organization.name }} {{/if}}Not too sure what I did wrong.
Any ideas?
Posts: 1
Participants: 1






