Fetch json() not returning

I have suddenly started experiencing some bizarre behavior when invoking a GET on a third party service. I’ve stripped down the code to the main bits:

function genericGet(uriSuffix) {
return new Promise( function(resolve, reject) {
getPPSessionToken()
.then( token => {
  return fetch(APIPREFIX + uriSuffix, { method: "get",
  headers: { token: token, "Content-Type": "application/json", username: INTEGRATIONEMAIL}
  });
})
.then( res => {
 if (!res.ok)
 throw new Error("error");
 else {
  console.log("returning json");
  return res.json();
 }
})
.then( json => {
console.log("get returning " + JSON.stringify(json));
 resolve(json);
})
.catch(err => console.error(err))
}

In my log I see “returning json” but NOT “get returning …”, nor do I see an error. Flow returns to the caller as if it succeeded but any attempt to reference the result value simply does not show up in the log. It’s as if this code returns a black hole and any attempt to reference it in this method or in the callers causes the code to stop working somehow.
This could be a problem on the other side of the API call, but Postman works just fine on the same URI and headers and I need to see if maybe I’m doing something wrong on the client. BTW I’ve tried adding these headers:

 "Connection": "keep-alive",
 "Accept-Encoding": "gzip",
 "Accept": "*/*",

but nothing seems to make a difference.

Before you run the .json() method, try to log the res to the console and see what you get.

If I add this line:

console.log("res: " + JSON.stringify(res));

inside the .then(res …) block, nothing appears in my log. If I also add this line:

console.log("got here!");

then that line appears in my log. Like I say, as soon as I try to find anything about the body, my code falls into a black hole. For example, this works:

console.log("header: " + JSON.stringify(res.headers));

and this is what I get (a couple of lines removed):
{
“_headers”: {
“date”: [“Mon, 31 Aug 2020 13:25:24 GMT”],
“content-type”: [“application/json; charset=utf-8”],
“transfer-encoding”: [“chunked”],
“connection”: [“keep-alive”],
“cache-control”: [“no-cache, no-store”],
“pragma”: [“no-cache”],
“expires”: [“-1”],
“x-aspnet-version”: [“4.0.30319”],
“x-powered-by”: [“ASP.NET”],
“access-control-allow-origin”: [“*”],
“access-control-allow-methods”: [“POST, GET, PUT”],
“access-control-allow-headers”: [“X-Requested-With, Origin, X-Csrftoken, Content-Type, Accept, accountid, username, authorization, token, twofactorcode, twofactortoken, rememberme”],
“cf-cache-status”: [“DYNAMIC”],
“expect-ct”: [“max-age=604800, report-uri=\“https: //report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\””],
“server”: [“cloudflare”],
“cf-ray”: [“5cb713ca59ccea62-IAD”],
“content-encoding”: [“gzip”]
}
}
So I can view the headers in the response, and check the OK status, but as soon as I touch the body I get the black hole.

I confirmed that the server that I am calling is not seeing any errors.

I figured out the problem. The default console log display is simply ignoring the log messages containing the fetch response body. The Stackdriver log displays all the messages - including the ones that the default one decides to skip.

Wix! Please fix your site monitor!!!