-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
queryRecord throws when the response is empty #3890
Comments
Here is a bin for JSONAPIAdapter http://emberjs.jsbin.com/fekufi/edit?js,console
|
@XrXr http://jsonapi.org/format/#fetching in JSONAPI payload can't be empty. you SHOULD return
or
|
I ran into this too. The JSON payload is intentionally empty though. Here's another contrived example: http://emberjs.jsbin.com/sikivanomi/edit?html,js,output. Simply put, my query found nothing on the back end. This was a valid response in ED 1.13, I don't see why my API response wouldn't be valid now. |
This works as expected // Returns books embedded in authors
$.mockjax({
type: 'GET',
url: '/authors',
status: '204',
dataType: 'json',
responseText: '{"data": []}'
}); |
I think the issue is more accurately stated as " |
@jherdman I think is because you are querying just a record, but you are returning an array (an empty one) |
Indeed, but that's how this jazz works. Peep this: data/packages/ember-data/lib/serializers/rest-serializer.js Lines 305 to 327 in 31bf071
This is the meat and potatoes of how the REST Adapter goes about figuring out which record to pluck out of a response when you're querying for a record. Indeed the adapter is expecting an array response. The trick seems to be further down in the stack. After this your normalized response look like this: |
but that's because REST adapter serialize plain JSON payload into JSON API compliant payload in order to let ED load it into the store |
Seems related to #3790 |
I am going to close this issue as the behavior of Please note that returning an array for the primary data of a |
http://emberjs.jsbin.com/fekufi/1/edit?js,console
If the payload for
authors
is changed tonull
, the same error happens.This use to just resolve with
undefined
in ED 1.3.x, so I assumed it's a convenience feature.I asked about this on Slack, the consensus seems to be that the promise should reject like a 404.
The text was updated successfully, but these errors were encountered: