I’ve attached a JS policy to one of my endpoints. In the policy, I call an URL that returns me some data and I add these data to the original response.
Something like
// Get the extra data from a thirdparty service
var fooData = httpClient.get('http://www.thirdparty.url/api');
fooData.waitForComplete();
// Here I wanna check if the response is a 200
if (fooData.isSuccess()) {
// Some logic
response.content = JSON.stringify(newContent);
}
AFAIK isSuccess
is true also if the url http://www.thirdparty.url/api returns a 4xx or a 5xx error.
How do I check if the url returned a 200 ?