-
-
Save aj07mm/f696bebc4aed96fe522b to your computer and use it in GitHub Desktop.
GET request call http/https nodejs
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
var https = require('https'), | |
http = require('http'), | |
optionsget = { | |
host : 'maps.googleapis.com', // here only the domain name | |
path : '/maps/api/directions/json?origin=Toledo&destination=Madrid®ion=es&key=key', // the rest of the url with parameters if needed | |
method : 'GET', // do GET | |
json:true | |
}; | |
// do the GET request | |
var reqGet = https.request(optionsget, function(res) { | |
res.on('data', function(d) { | |
process.stdout.write(d); | |
}); | |
}); | |
reqGet.end(); | |
reqGet.on('error', function(e) { | |
console.error(e); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment