Hello i am new to apigee .I need to call an two apis with 2 seconds time out.Get few attributes as response from the api.

Not applicable

This is the code i wrote upto now in Node.js.

var express= require('express');

var request = require('request');

var app=express(); var async = require('async');

var url = 'URL';

var url2 = 'URL';

async.parallel([ request(url, function (error, response, body) { setTimeout(function(){

if (!error && response.statusCode == 200)

{ var ups = JSON.parse(body); console.log("Got a response: ", ups); }

else { console.log("Got an error: ", error, ", status code: ", response.statusCode); } },2000);

})

request(url2, function (error, response, body) {

if (!error && response.statusCode == 200)

{ var dhl = JSON.parse(body); console.log("Got a response: ", dhl); }

else { console.log("Got an error: ", error, ", status code: ", response.statusCode); } })

);

app.listen(8001,function (req,res) { console.log('Server running at http://127.0.0.1:8001/'); });

0 5 388
5 REPLIES 5

Not applicable

The code i wrote is also having some syntax issues.

Is there a specific Apigee related question here?

Not applicable

Yes i just want to know the process .Like once i get the response how to aggregate the response .Should i use node.js or apigee edge ?

adas
Participant V

@Nikhil Preeth I am attaching a sample proxy where I am doing something similar. I have used multiple javascript callouts to fetch some data and then I aggregate that response and send that back as the API response to the caller.

Instead of javascript you might use node.js too. Apigee Edge provides support for node.js so that you can run node.js within the Apigee runtime gateway.apigee-weather-rev14-2016-01-12.zip

NOTE: The policy has some extra policies, which you may not worry about. You can simply disable those policies by makine enabled=false.

Let me know, if this answers your question and also accept the answer so that it helps other fellow developers in the community.

For new readers of this answer.....Apigee has removed the nodejs support described above from the product.