Reputation: 3123
I am making an API call to get the conference rooms that match the profided filters. The response is returning an array, however Ember is giving me the error:
Error while processing route: rooms Assertion Failed: The response to store.query is expected to be an array but it was a single record. Please wrap your response in an array or use store.queryRecord
to query for a single record.
I am using RESTAdapter.
What am I doing wrong?
route:
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return this.store.query('room', { filter: { option1: 'x', option2: 'y' } }).then(function(rooms) {
return rooms;
});
}
});
Returned by server:
{"rooms":[
{"id":"1","size":"600","title":"Centennial Room","description":""},
{"id":"3","size":"1500","title":"Grand Auditorium","description":""}
]
}
Thank you.
Upvotes: 1
Views: 1700
Reputation: 3123
The problem was with pluralization. I'm using pods, and the folder's name (and therefore the model's name, and the URL) was rooms
. I changed it to room
and the error went away.
There was also an ember warning, but I ignored it, paying attention to the error instead. Fixing the warning would have fixed the error.
Upvotes: 2