Created
August 10, 2010 04:58
-
-
Save ivarvong/516706 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDirections(data) { | |
var responseBody = ""; | |
requestStr = "/m/directions?dirflg=r&saddr=" + escape(data.from) + "&daddr=" + escape(data.to); | |
console.log(requestStr); | |
var client = http.createClient(80, 'www.google.com'); | |
var request = client.request('GET', requestStr, {'host': 'www.google.com'}); | |
request.end(); | |
request.on('response', function (response) { | |
response.setEncoding('utf8'); | |
response.on('data', function (chunk) { | |
responseBody += chunk; | |
}); | |
response.on('end', function(data) { | |
//here i parse data, then i want to return it. | |
//but how do i get it to be the return value for getDirections() ? | |
//if i return here, it's just the return value of the anonymous function, right? | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment