I am using Properties in Apigee Edge to store key value pairs. When I try to read the keys it gives null value org.mozilla.javascript.Undefined@0
below one is my javascript file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- vesrion maintainance-->
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="EXT-JS-VersionKeyGenerator">
<DisplayName>EXT-JS-VersionKeyGenerator</DisplayName>
<Properties>
<!--version1-->
<Property name="ecommerce.redirect.orders.01-01-24">v1</Property>
<Property name="ecommerce.redirect.payments.01-01-24">v1</Property>
<Property name="ecommerce.redirect.users.01-01-24">v1</Property>
<Property name="ecommerce.redirect.Authentication.01-01-24">v1</Property>
<!--version2-->
<Property name="ecommerce.redirect.orders.01-01-25">v2</Property>
<Property name="ecommerce.redirect.payments.01-01-25">v2</Property>
<Property name="ecommerce.redirect.users.01-01-25">v2</Property>
<Property name="ecommerce.redirect.Authentication.01-01-25">v2</Property>
</Properties>
<ResourceURL>jsc://versionKeyGenerator.js</ResourceURL>
</Javascript>
In following file I am trying to access it versionKeyGenerator.js
// get the version from request header + URI
var targetUrl = context.getVariable("target.url");
var pathSuffix = context.getVariable('proxy.pathsuffix');
var reqVersion = "EC-Version";
function orders() {
return pathSuffix.includes("/order");
}
function payments() {
return pathSuffix.includes("/pay");
}
var conditions = [
{ condition: orders, value: "orders" },
{ condition: payments, value: "payments.ecommerce" }
];
var matchingCondition = conditions.find(cond => cond.condition());
var requestPath = matchingCondition && matchingCondition.value || null;
reqVersion = "ecommerce.redirect."+ requestPath +'.'+ reqVersion;
context.setVariable("redirect.version", JSON.stringify(properties[reqVersion]));
Solved! Go to Solution.
Hi I think this is the third version of this question that you asked. And you've answered in one of the other questions. So I think this is resolved.
Hi I think this is the third version of this question that you asked. And you've answered in one of the other questions. So I think this is resolved.
I appreciate your reply. This one was unique in that, although the code was functioning, the routing version I was sending was incorrect due to improper handiling logic for versioning. however, the code is functional.