Unable to access properties in javascript

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]));

 

Is there anything I am missing here.  @dchiesa1   @omidt 

Solved Solved
0 2 253
1 ACCEPTED 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. 

View solution in original post

2 REPLIES 2

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. 

appreciate your reply. This one was unique in that, although the code was functioning, the routing version was sending was incorrect due to improper handiling logic for versioning. however, the code is functional.