# How to get belongsTo object

**URL:** <https://discuss.emberjs.com/t/how-to-get-belongsto-object/16153>\
**Category:** Questions\
**Created:** [February 11, 2019, 7:03pm UTC](https://discuss.emberjs.com/t/how-to-get-belongsto-object/16153 "2019-02-11T19:03:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wowember](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@wowember](https://discuss.emberjs.com/u/wowember)\
**Post date:** [February 11, 2019, 7:03pm UTC](https://discuss.emberjs.com/t/how-to-get-belongsto-object/16153/1 "2019-02-11T19:03:06Z")

</div>

How do you interact with a model’s belongsTo relationships?

If I have a model:

model-with-references.js

```
export default DS.Model.extend({
  referenced_thing: DS.belongsTo('thing'),
  referenced_thing_async: DS.belongsTo('thing_async', {async: true})
});

```

Then in a route or a controller, how do I do:

```
let referenced_thing =
    this.get('modelWithReferences')
            .howToGetTheReferencedThing()

let referenced_thingAsync = 
    this.get('modelWithReferences')
            .howToGetTheReferencedThingAsync()

```

---

<div class="post-metadata">

**Author:** ![sukima](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/sukima/32/5773_2.png) [@sukima](https://discuss.emberjs.com/u/sukima)\
**Post date:** [February 11, 2019, 9:40pm UTC](https://discuss.emberjs.com/t/how-to-get-belongsto-object/16153/2 "2019-02-11T21:40:19Z")

</div>

First in your example `referenced_thing` and `referenced_thing_async` are **both** async. By default ember-data makes all relationships async.

When a relationship is async the value it offers is a **proxy** to the actual result. You would have to explicitly set `{ async: false }` to remove the proxy involved. However, this assumes that you have side loaded ember-data with the real information in some way (perhaps via JSON:API `includes`).

The proxy offers the following properties and methods since it is an implementation of Ember’s [PromiseProxyMixin](https://emberjs.com/api/ember/release/classes/PromiseProxyMixin):

- [catch()](https://emberjs.com/api/ember/3.7/classes/PromiseProxyMixin/methods/catch?anchor=catch)
- [finally()](https://emberjs.com/api/ember/3.7/classes/PromiseProxyMixin/methods/finally?anchor=finally)
- [then()](https://emberjs.com/api/ember/3.7/classes/PromiseProxyMixin/methods/then?anchor=then)
- [isFulfilled](https://emberjs.com/api/ember/3.7/classes/PromiseProxyMixin/properties/isFulfilled?anchor=isFulfilled)
- [isPending](https://emberjs.com/api/ember/3.7/classes/PromiseProxyMixin/properties/isPending?anchor=isPending)
- [isRejected](https://emberjs.com/api/ember/3.7/classes/PromiseProxyMixin/properties/isRejected?anchor=isRejected)
- [isSettled](https://emberjs.com/api/ember/3.7/classes/PromiseProxyMixin/properties/isSettled?anchor=isSettled)
- [reason](https://emberjs.com/api/ember/3.7/classes/PromiseProxyMixin/properties/reason?anchor=reason)

Specifically if you plan on using _the referenced thing_ in JavaScript land you might do this–

```nohighlight
// Modern Ember
let referenced_thing
  = await this.get('modelWithReferences.referenced_thing');
// ember-concurrency
let referenced_thing
  = yield this.get('modelWithReferences.referenced_thing');
// Older Vanilla Ember
this.get('modelWithReferences.referenced_thing')
  .then(referenced_thing => {
    // referenced_thing is available in here
  });

```

In templates you can use the derived state–

```nohighlight
{{#let modelWithReferences.referenced_thing as |thing|}}
  {{#if thing.isPending}}
    Loading thing&hellip;
  {{else if thing.isRejected}}
    Error: {{thing.reason}}
  {{else}}
    {{thing.proxied_property_of_some_kind}}
  {{/if}}
{{/let}}

```
