Was going through this page and came across the below:
<TargetEndpoint name="default"> <ScriptTarget> <ResourceURL>node://hello.js</ResourceURL> <EnvironmentVariables> <EnvironmentVariable name="NAME">VALUE</EnvironmentVariable> </EnvironmentVariables> <Arguments> <Argument>ARG</Argument> </Arguments> </ScriptTarget> </TargetEndpoint>
Here the VALUE cannot be dynamic?
I know, I can use apigee-access module (apigee.getVariable(req,"flow.variable")), to access these in Node. However, I do not always have access to the req parameter all the way down.
Is it possible to set dynamic arguments to Node application via the TargetEndpoint configuration?
In my use case, I would be looking up values on the KVM and these would be fetched by appropriate layers on Node. I do not have to rely on passing the req parameter all the way down, just to access the flow variable (via apigee-access). Any suggestions/alternatives on how to best achieve this?
Thanks,
Girish
Solved! Go to Solution.
Dear @Girish Gajria, you're right about setting dynamic values from variables in Node.js as environment variables. Therefore, you won't be able to leverage them for the purpose of passing values dynamically. However, based on your use case, you can leverage many other features available in Apigee Edge to retrieve dynamic variables. I'll try to sumarize the ones I'm familiar with:
Am I missing anything?
Dear @Girish Gajria, you're right about setting dynamic values from variables in Node.js as environment variables. Therefore, you won't be able to leverage them for the purpose of passing values dynamically. However, based on your use case, you can leverage many other features available in Apigee Edge to retrieve dynamic variables. I'll try to sumarize the ones I'm familiar with:
Am I missing anything?
Thanks @Diego Zuluaga. So I guess 1st option is the (only) best option. The only issue is due to the callback pattern of node.js, now I need to pass the req variable to all of the deepest functions. I was looking for a way to avoid this, oh well.
Thanks Again,
Girish
Essentially yes. But I know where you're coming from and I've run into similar scenarios. There maybe a few ways to workaround or reduce the dependency:
All in all, if you follow MVC pattern, the request object should be part of the parameter of the controller, so at that point, I'd recommend getting the variable from the request.
Hope it helps!
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |