Search code examples
ember-data

Assertion Failed: Expected the primary data returned by the serializer for a `queryRecord` response to be a single object but instead it was an array


I have just got this error a few days ago. Whenever I try to run

this.store.queryRecord('user', {filter:{username : params.username}});

It shows error: Assertion Failed: Expected the primary data returned by the serializer for a queryRecord response to be a single object but instead it was an array.

What is the problem here?


Solution

  • Found a way to avoid this problem. Instead of queryRecord ( which seems to be changed by ember-data developer team ), I use store.query like this:

    this.store.query('user', {filter:{username : params.username}}).then(function(user){return user.get('firstObject')});