Created
December 2, 2015 22:28
-
-
Save samueleresca/30e4366fc496d2075a2d 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
//DEPENDENCIES | |
var express = require('express'); | |
//Initialize Express.js | |
var app = express(); | |
//JSONP Get Request | |
app.get('/endpointJSONP', function(req, res){ | |
//LOG | |
console.log('JSONP response'); | |
console.log(req.query); | |
//JSONP Response (doc: http://expressjs.com/api.html#res.jsonp) | |
res.jsonp(req.query) | |
}); | |
//JSON Get Request | |
app.get('/endpointJSON', function(req, res){ | |
//LOG | |
console.log('JSON response'); | |
console.log(req.query); | |
//JSON Response | |
res.json(req.query); | |
}); | |
//Starting the server | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment