Reputation: 93
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
Upvotes: 0
Views: 109
Reputation: 93
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.
Upvotes: 0
Reputation: 531
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.
Upvotes: 0