Please find the code snippet that i used for making service callout in javascript:
var headers = {'Accept' : 'application/json'};
var request = new Request("targetURL", "GET", headers, "");
var exchange = httpClient.send(request), response, status;
exchange.waitForComplete();
print("exchange.getResponse.status:" + exchange.getResponse().status);
Response:
{ "fault": { "faultstring": "Execution of responseMapping failed with error: Javascript runtime error: \"TypeError: Cannot read property \"status\" from undefined (Test_js#7). at line 7 \"", "detail": { "errorcode": "steps.javascript.ScriptExecutionFailed" } } }
Request is received in target endpoint and it returns a success response. But response from target is not readable in javascript callout. Have anyone ever faced this issue. Kindly help.