How to make a call to target server via Javascript callout?

It's quite straightforward in apigee edge to make a call to a static url from a javascript callout (via httpClient). My query is, how to leverage TargetServers via the javascript callouts. My specific scenario is that I want to make 2 calls in parallel to my backend and mashup the response. Now, I can use Service callouts and still use my TargetServers; however these calls will now be sequential.

Solved Solved
2 6 1,774
1 ACCEPTED SOLUTION

Interesting question I must say .

I don't think there is anyway to invoke target Server from javascript.

There is also no way to make parallel service callouts OOB.

However I think using node.js inside Apigee you can do it , rather easily.

You can probably leverage modules like https://www.npmjs.com/package/node-parallel

View solution in original post

6 REPLIES 6

Interesting question I must say .

I don't think there is anyway to invoke target Server from javascript.

There is also no way to make parallel service callouts OOB.

However I think using node.js inside Apigee you can do it , rather easily.

You can probably leverage modules like https://www.npmjs.com/package/node-parallel

Thanks for the response Sarthak. However with a targetserver I can setup keystore and truststore for configuring 2-way ssl. Can the same be achieved via nodejs?

Yes you can. You can see here : http://apigee.com/docs/api-services/content/configuring-ssl-edge-backend-service . It has a section on 2 way SSL for node apps.

@Cladius Fernando

, as @sarthak said, the recommended way would be to use node.js to make the target server callouts.

However, you could also use javascript if you really wished to do this. You can use the httpClient object in javascript to make two parallel calls and receive the results in a later javascript. However you would have to do away with the target server completely, so that you can achieve a parallel result. (please refer links below) https://community.apigee.com/articles/2340/asynchr...

http://apigee.com/docs/api-services/reference/java...

Of course, using either a node.js or javascript callout, you give away a lot of benefits of using the target server, so use this with due consideration.

adas
New Member

@Cladius Fernando One other thought is to use service callouts to get the various target server urls using the management api and then store that in cache or kvm (so that you dont make too many mgmt api calls during runtime). Once that is done, you can fetch the urls from kvm and make async javascript callouts and mashup the response. The only catch here is, your runtime would have some level of dependency on the management apis to fetch the targetservers.

Not applicable

@Cladius Fernando - Faced the same issue; Finally used KVM.