Is let keyword of javascript not supported in apigee

Hi

When I m trying to declare a variable using let keyword I am getting this error,

Error creating object
Compilation of JavaScript jsc://ExtractPathVariableOrQueryParam.js failed with error:Compilation error: missing ; before statement (JSC_ExtractPathVariableOrQueryParam#7). Line:7, column:23. Source is:let resourceId = context.getVariable('proxy.pathsuffix').substring(resourceIdPath.length).split('/')[0];. Context Revision:10;APIProxy:flow-something;Organization:asif-nonprod;Environment:pre-prod .

my code snippet of javascript is

extractResourceId(resourceIdLocation, resourceIdPath);

function extractResourceId(resourceIdLocation, resourceIdPath) {
if (resourceIdLocation == "PATH_VARIABLE") {
let resourceId = context.getVariable('proxy.pathsuffix').substring(resourceIdPath.length).split('/')[0];
context.setVariable('custom.resourceId', resourceId);
return;
}
let resourceId = context.getVariable('request.queryparam.'.concat(resourceIdPath));
context.setVariable('custom.resourceId', resourceId);
return;
}

just trying to get id either from pathvariable or queryparam in above logic

but with let keyword I m getting error that I have already pasted.

with var it is working fine.

Is let keyword of javascript is not supported in apigee ?

0 2 241
2 REPLIES 2

Sadly no; check out https://cloud.google.com/apigee/docs/api-platform/reference/policies/javascript-policy which says:

"Apigee supports JavaScript that runs on the Rhino JavaScript engine 1.7.13."

If you pop open https://mozilla.github.io/rhino/compat/engines.html you can find how far behind browsers rhino is, including complete lack of support for let.

 

Thanks