Nijikokun
Nijikokun

Reputation: 1524

Ember-DS queryRecord returns TypeError: Cannot convert undefined or null to object

I'm trying to do a queryRecord search inside of my model function and I seem to be hitting an error:

TypeError: Cannot convert undefined or null to object

My model() looks like the following:

model() {
  return this.store.queryRecord('model', { property: 'value' })
    .then(doc => console.log(doc)) // This doesn't even invoke
}

Upvotes: 0

Views: 278

Answers (1)

Nijikokun
Nijikokun

Reputation: 1524

The reason for this error is due to the XHR or REST API returning null or undefined as the response instead of an empty Object or Array.

> GET /model?query=x
< null

should be

> GET /model?query=x
< {}

Upvotes: 1

Related Questions