# Fetch nested relationship data fails

**URL:** <https://discuss.emberjs.com/t/fetch-nested-relationship-data-fails/12718>\
**Category:** Ember Data\
**Created:** [April 3, 2017, 5:59pm UTC](https://discuss.emberjs.com/t/fetch-nested-relationship-data-fails/12718 "2017-04-03T17:59:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![devtoro](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@devtoro](https://discuss.emberjs.com/u/devtoro)\
**Post date:** [April 3, 2017, 5:59pm UTC](https://discuss.emberjs.com/t/fetch-nested-relationship-data-fails/12718/1 "2017-04-03T17:59:46Z")

</div>

I cannot fetch nested relationship from the store of my ember application. The relationship is as follows:

project \<=\> client \<=\> offices.

Versions:

Ember: 2.12.0 Ember Data: v2.12.1

Here are my models:

project: import DS from ‘ember-data’;

```
export default DS.Model.extend({
  title: DS.attr('string'),
  client: DS.belongsTo('client')
});

```

client:

```
import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr('string') ,
  projects: DS.hasMany('project'),
  offices: DS.hasMany('office')
});

```

office:

```
import DS from 'ember-data';
export default DS.Model.extend({
  country: DS.attr('string'),
  client: DS.belongsTo('client')
});

```

Here is my route:

```
import Ember from 'ember';

export default Ember.Route.extend({
  model(params) {
    return this.get('store').findRecord('project', 1);
  }

```

The requested “offices” are in the payload from the server and are stored in the store. In my route, my model is a project object. The client of the project has 2 offices. When I try to fetch the client, everything works like a charm. When I additionally try to fetch the client’s offices I get 0 records. This is how I try to fetch them:

let client = model.get(‘client’); client.get(‘offices’);

When the promise is resolved, there are no records.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Hummingbird](https://avatars.discourse-cdn.com/v4/letter/h/59ef9b/32.png) [@Hummingbird](https://discuss.emberjs.com/u/Hummingbird)\
**Post date:** [April 10, 2017, 6:09pm UTC](https://discuss.emberjs.com/t/fetch-nested-relationship-data-fails/12718/2 "2017-04-10T18:09:06Z")

</div>

I think I was running into a similar issue: [EmbeddedRecordsMixin: Embedded hasMany is only visible after explicitly calling store.find()](https://discuss.emberjs.com/t/embeddedrecordsmixin-embedded-hasmany-is-only-visible-after-explicitly-calling-store-find/12744) I needed to wait for the hasMany relationship to be fulfilled before I was able to get the correct data. something like: `client.get('offices').then((offices) => { console.log(offices.get('length'); });` should get you going. However, you might want to take this with a grain of salt, as I am not 100% sure if this really is exactly what is going on under the hood.
