How to read target server host value in JavaScript in Apigee X

Hi All,

 

I am calling multiple target servers on bases of different API host name using same API proxy. currently we are using resource file(java script) to route target servers on bases of API host value.

priyashikhar_1-1646633952092.png

Please help us, I am trying to get target servers value in java script file but not working ,so whenever target servers changes will come we need to update target server value instead of changes in resource file.

Kindly advice if it is the best way or we can follow another approach to achieve this.

@davissean @adevegowda @dchiesa1 

1 1 313
1 REPLY 1

I am calling multiple target servers on bases of different API host name using same API proxy.

OK, sounds good.

currently we are using resource file(java script) to route target servers on bases of API host value.

OK. But can you provide more details? There is a specific item called "Target Server" within Apigee (documentation here). If you are using JavaScript to select a target, you are not using that mechanism. How exactly are you using JavaScript? What does it do? If you are simply mapping between inbound hostname and a target, on a 1:1 basis, you can do that with RouteRules. You don't need any JavaScript for that. On the other hand if you are mapping on a 1:n or n:1 or m:n basis, then probably you would be better served to use JavaScript.

I am trying to get target servers value in java script file but not working

Yep, I can try to help you but I don't know what you mean by "trying to get target servers value." Maybe show some actual code and I can try to help sort it out with you.

whenever target servers changes will come we need to update target server value instead of changes in resource file.

I'm not following. I don't understand this. More details please.