0

I am using usergrid module of node.js on my one machine, but now I got my new laptop, and installed all the required packages on laptop, but here the execution of usergrid module fails, while the same code and same modules gets executed on my machine.

Can anyone help me with this?

and what I am trying to execute is below.

app.get('/discovery', function(req, res, next) {
var providerId = req.query.providerId;
discovery(providerId, function(error, result){
    if(error){
        res.json(error);
    }else{
        res.json(result);
    }
});

});

The error that comes is :

D:\REPOS\Exchange>node main.js calling: GET https://api.usergrid.com/abc/test/abc_servers D:\REPOS\Exchange\node_modules\usergrid\lib\usergrid.js:112 r.body = r.body || {}; TypeError: Cannot read property 'body' of undefined

Yeahia2508
  • 7,526
  • 14
  • 42
  • 71

2 Answers2

0

I think I see the problem with your code. It looks like you are trying to do a GET to the /discovery collection. You have this line:

app.get('/discovery', function(req, res, next) {

But what you want is this:

var options = {
    method:'GET',
    endpoint:'discovery'
};
app.request(options, function (err, data) {

I may not understand what you are trying to do. Feel free to post more details or more complete code and I will take a closer look.

rockerston
  • 521
  • 2
  • 10
  • actually the problem is not with the code, the problem was with network proxy. and the /discovery is the path for this specific API, the collection name is something different, thanks for reply rockerston :) – Sushank Dahiwadkar Jul 10 '15 at 06:56
0

The problem was not related to code. The problem was related to the network i was working it. Firewall and the proxy server was not allowing connection to target server.