Last active
September 10, 2015 13:49
-
-
Save sponnet/83baf52aba8b7ac317f1 to your computer and use it in GitHub Desktop.
jsonp express example jongen
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 express = require('express'); | |
var request = require('request'); | |
var app = express(); | |
app.get('/', function(req, res) { | |
var street = "Beekvelden"; | |
var postal = "2840"; | |
request.get({ | |
url: 'http://www.ophaalkalender.be/calendar/findstreets?query=' + street + '&zipcode=' + postal | |
}, function(error, response, body) { | |
//res.send(body); | |
res.jsonp(JSON.parse(body)); | |
}); | |
}); | |
var server = app.listen(3000, function() { | |
var host = server.address().address; | |
var port = server.address().port; | |
console.log('Example app listening at http://%s:%s', host, port); | |
}); | |
// En nu suffen naar http://localhost:3000/?callback=blabla | |
// resultaat | |
// /**/ typeof blabla === 'function' && blabla({"Hello":"flurkie"}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment