Is there support for ES2018 in apigee? Can I use object spread (...) in apigee js policy?

I’m trying to construct a json response in a stub setup in Apigee. Based on different use cases I’ve used object spread (…) operation for dynamic json construction. As I try to deploy in Apigee, I get an error. This worked fine in other environments. Doesn’t apigee support ES2018 features? What’s the alternative to a spread operation supported by apigee ? For eg: I’ve the below program that uses spread. Can you recommend another way to achieve the same if spread is not supported in apigee?

const original = {
“product”: {
“prodId”: “PROD100”
},
“packages”: {
“pkgId”: “PKG137”
},
“discount”: “50”,
“periodFrom”: null,
“periodTo”: null,
“totalAmount”: “599”,
“isActive”: “false”
}const toAppend = {
“customer”: {
“custId”: “CUST1002”
},
}

const newJSON = { …toAppend, …original};

console.log(newJSON);

It outputs -

{
customer: { custId: ‘CUST1002’ },
product: { prodId: ‘PROD100’ },
packages: { pkgId: ‘PKG137’ },
discount: ‘50’,
periodFrom: null,
periodTo: null,
totalAmount: ‘599’,
isActive: ‘false’
}

No, the Apigee JS callout relies on Rhino 1.7.13, and the current Rhino does not support spread syntax.

The alternative is to implement a “object clone” function in your JS. Some suggestions here.