# TypeError: Cannot read property 'type' of undefined

**URL:** <https://discuss.emberjs.com/t/typeerror-cannot-read-property-type-of-undefined/17747>\
**Category:** Ember Data\
**Created:** [April 8, 2020, 5:22pm UTC](https://discuss.emberjs.com/t/typeerror-cannot-read-property-type-of-undefined/17747 "2020-04-08T17:22:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@Frank](https://discuss.emberjs.com/u/Frank)\
**Post date:** [April 8, 2020, 5:22pm UTC](https://discuss.emberjs.com/t/typeerror-cannot-read-property-type-of-undefined/17747/1 "2020-04-08T17:22:42Z")

</div>

I get this error `TypeError: Cannot read property 'type' of undefined` from a `this.store.query('record-type', { id : someId }` call. I get a 200 reponse from the backend with the same JSON format that I get elsewhere in my app, like this

```
{
"id": int,
"attr1": "string",
"attr2: "string",
etc.
}

```

but I can’t access the object in ember. Reading a bit around it seems this might be related to a serializer issue, but I a little bit lost here. I don’t understand why in that specific case I would need to serialize whereas I don’t need to do it with the other models in my app, nor exactly how serializer works, even after reading the doc on it.

Here is my `model`

```
import DS from 'ember-data';
const { Model, attr, belongsTo } = DS;

export default Model.extend({
  autoClose: attr('boolean'),
  capaRequired: attr('boolean'),
  carNumber: attr('string'),
  conclusion: attr('string'),
  dispositionId: attr('number'),
  dispositionName: attr('string'),
  impactInfo: attr('string'),
  instructions: attr('string'),
  issueType: belongsTo('issue-type'),
  needsConfirmation: attr('boolean'),
  priority: attr('string')
});

```

Anyone has any idea what I am doing wrong?

Thanks!

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [April 8, 2020, 5:53pm UTC](https://discuss.emberjs.com/t/typeerror-cannot-read-property-type-of-undefined/17747/2 "2020-04-08T17:53:00Z")

</div>

> [@Frank](#):
>
> { “id”: int, “attr1”: “string”, "attr2: “string”, etc. }

`query` expects an array response, so i’m guessing that’s part of your problem. You could try `queryRecord`, or if this is the format that your API uses for fetching singular records (instead of something like `/recordType/:id` then you could customize your adapter and just use `store.findRecord`

---

<div class="post-metadata">

**Author:** ![Frank](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@Frank](https://discuss.emberjs.com/u/Frank)\
**Post date:** [April 8, 2020, 5:58pm UTC](https://discuss.emberjs.com/t/typeerror-cannot-read-property-type-of-undefined/17747/3 "2020-04-08T17:58:05Z")

</div>

Thank you very much for the fast reply!

And you are right. With `queryRecord`, everything works. I was under the false impression that you could not pass a query object to `queryRecord`, but after your answer I went to re-read the doc and it says

> As in the case of `store.query()` , a query object can also be passed to `store.queryRecord()` and is available for the adapter’s `queryRecord()` to use to qualify the request.

Again, thanks a lot!

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [April 8, 2020, 6:45pm UTC](https://discuss.emberjs.com/t/typeerror-cannot-read-property-type-of-undefined/17747/4 "2020-04-08T18:45:14Z")

</div>

Glad you got it working! Sometimes fitting the right ember data paradigm to your API can be weird.
