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
afterFetchmiddleware functions weren't being called because of various short-circuiting logic withinRequest#_handleResponse.Behavior changes
DELETEand getting a200response, it will now try to parse that body. Prior to this change-set, it would skip.200should be returned if there is only top-level meta data in the response. Presumably, thatmetawould be useful to be able to access.dataandmetabeingundefinedrather than justdata(aside from a JSON parse error).metabeing defined is valid.afterFetchcalls happen withjson=nullin 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
204be returned by the server. Should we remove the ability for non-204responses to be empty?The default
jsonbody ofnullwas 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 Objectdefault that'll explain where it came from (empty body) on field access?