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.