I am new to Nodejs, writing a very simple app with a function that makes an API call to another service running locally.
Code looks like this:
var request = require('request');
module.exports = {
tokenize: function(text){
        console.log("Request to tokenize.");
        var ServerEndpoint = 'http://localhost:3002/id/'+text;
        var secureresponse = "Server didn\'t respond.";
        var req = request.get(ServerEndpoint, card, function(err, response, body){
            if (!err && response.statusCode == 200){
                secureresponse = body;
            }else{
                secureresponse = "Server didn\'t respond.";
            }
        }).end();
        return secureresponse;
    }
};
Then running the tokenize function always returns "Server didn't respond.", while putting a console.log(body) right below "secureresponse = body;" does print the body on the console.
What am I missing?
Thanks!
