I have a javascript to extract the single key from set of keys that has use == enc && !expired = true but the javascript was able to fetch the list of full json rsa keys from service callout response but failing suddenly stating . its in apigee edge.
Javascript runtime error: “SyntaxError: Unexpected token: . (Extract-EC-Key.js:4)”
Javascript:
var response = context.getVariable(“ServiceCallout.response”);
var json = JSON.parse(response);
var keys = json.keys;
const keysArray = keys.reduce((acc, item)=>{
if (item.use === “enc” && !item.expired) {
acc.push(item);
}
return acc;
},[])
context.setVariable(“keysArray”, JSON.stringify(keysArray[0]));
Does apigee edge support const and reduce with =>{} function because apigee javascript uses rhino javascript engine 1.7.12
@Dino @dchiesa1 Can you let me know the reason for failing and the fix.
