Don't skip afterFetch in cases where there's no response body. #35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The original error was that the
afterFetch
middleware functions weren't being called because of various short-circuiting logic withinRequest#_handleResponse
.Behavior changes
DELETE
and getting a200
response, it will now try to parse that body. Prior to this change-set, it would skip.200
should be returned if there is only top-level meta data in the response. Presumably, thatmeta
would be useful to be able to access.data
andmeta
beingundefined
rather than justdata
(aside from a JSON parse error).meta
being defined is valid.afterFetch
calls happen withjson=null
in the case of a204 No Content
.Questions:
The spec for deleting resources does not specify if a response body MUST be returned. However, you could interpret that "a deletion request has been accepted for processing ... and no content is returned" requires that a
204
be returned by the server. Should we remove the ability for non-204
responses to be empty?The default
json
body ofnull
was chosen instead of an empty object because it's representing the absence of a body; I figured just{}
would be confusing (but I also don't like giving people NPE). Do you think we should introduce someNull Object
default that'll explain where it came from (empty body) on field access?