[wp-trac] [WordPress Trac] #49252: REST API response not valid for null on 5.3.2
WordPress Trac
noreply at wordpress.org
Fri Feb 21 15:16:57 UTC 2020
#49252: REST API response not valid for null on 5.3.2
-------------------------------------+------------------------------
Reporter: jankadlec | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 5.3
Severity: normal | Resolution:
Keywords: reporter-feedback close | Focuses:
-------------------------------------+------------------------------
Comment (by chrisl27):
Hi @TimothyBlynJacobs
I've found this ticket as a result of seeing "null" no longer be sent, in
our case we are response.json()'ing the fetch responses from the API,
which is now failing if the response has no body because
JSON.parse("null") is valid, but JSON.parse("") throws. This is also a
problem because the API is saying "Content-Type: application/json" but the
response wasn't valid JSON - so there's not really a way (apart from
try/catching) to determine whether we should expect the content to be
valid JSON.
Should the fix have been {{{&&}}} instead of {{{||}}} so as to only have
this behaviour for 204 responses?
{{{
if ( 204 === $code && null === $result ) {
return null;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49252#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list