Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Node js code works in local machine but not working in Apigee.

Not applicable

The below code works in local machine when executed by Node.js module. But its throwin error "Cannot GET/" when run in Apigee cloud. Pls help.

var request = require('request');
var express = require('express');
var async = require('async');
var app = express();
var output,jsonRes1;


 async.parallel([
 function(callback) {
	request('https://api.usergrid.com', function (error, response, body) {
		if (!error && response.statusCode == 200) {
			jsonRes1 = JSON.parse(body);
		}
	});
 },	function(callback) {
	setTimeout(function() {
  request('https://api.usergrid.com', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    var jsonRes2 = JSON.parse(body);
	 output = {'Output':{'Response1':{'Time':jsonRes1.timestamp,'Period':jsonRes1.duration}},'Response2':{'Start':jsonRes2.status.started,'CountryCode':jsonRes2.status.uptime}};
    console.dir(output);   
  }
});
	},2000);
	}
],
 function(error, results) {
  console.log(results);
});


app.listen(8001,function (req,res) {
  console.log('Server running at http://198.1.2.3:8888/');
     });
0 8 613
8 REPLIES 8
Top Solution Authors