When I am trying to read the cache-hit variable inside JavaScript policy. JS policy execution got failed and I see the following error on Message processor System.log.
RhinoExecutor$TopLevelScope.print() : ReferenceError: "lookupcache" is not defined.
JavaScript policy JS File code:
if(lookupcache.{policy-name}.cachehit !==true){ ///code }
FYI information - LookUpCache policy is executing before JS policy.
The JavaScript API does not expose "lookupcache", please review the JavaScript reference for more details: https://docs.apigee.com/api-platform/reference/javascript-object-model
Yes. And I think the OP needs something more like this :
var cachehit = context.getVariable('lookupcache.POLICYNAME.cachehit'); ...
The key observation here:
variables in the Apigee request context (aka context variables) are contained in a scope that is different than variables inside the JavaScript execution context.
To access a context variable in a JS, you need to use "context.getVariable()" from within your JS.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |