Apigee Javascript policy doesn't support Optional chaining (?.)

For some reason, Apigee Javascript policy doesn't support operational chaining operator i.e. ?. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining), is that correct? I'm getting the below error when I'm trying to save the proxy from the Apigee Edge UI developer tool -

Error Saving Revision 4
Compilation of JavaScript jsc://Javascript.Javascript-1.js failed with error:Compilation error: syntax error (Javascript_Javascript-1#5). Line:5, column:41. Source is:print(responseData?.data?.items);. Context Revision:4;APIProxy:my-proxy;Organization:my-nonprod-org;Environment:dev

I still wonder which version of JS is used by Apigee Javascript policy.

0 3 257
3 REPLIES 3

For some reason, Apigee Javascript policy doesn't support operational chaining operator.

That does not surprise me.

I still wonder which version of JS is used by Apigee Javascript policy.

Wonder no longer! The documentation page states that Apigee's JavaScript callout policy is based on Rhino v1.7.13.

js-rhino-1.7.13.png

This matrix might help you determine if/when a feature is available in various versions of Rhino.

If you want to test things offline, you can clone the Rhino repo and run your own tests locally.

It uses the Rhino JavaScript engine 1.7.12. Unless it's different than what is listed here: https://docs.apigee.com/release/supported-software. So I think that rules out basically all modern JavaScript niceties.

You could, in theory, use TypeScript and then do whatever you want: https://www.googlecloudcommunity.com/gc/Cloud-Product-Articles/Getting-Started-JS-Testing-Debugging-...

 

Right -

Just to clear any confusion, according to the product documentation, 

  • the older Apigee Edge uses Rhino 1.7.12
  • Apigee X and hybrid uses Rhino 1.7.13