Skip to content

Instantly share code, notes, and snippets.

@dscape
Last active December 20, 2015 18:09
Show Gist options
  • Save dscape/6174370 to your computer and use it in GitHub Desktop.
Save dscape/6174370 to your computer and use it in GitHub Desktop.
<html>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$.getJSON('http://localhost:3000/athlete/1', function(data) {
console.log(data);
});
</script>
</html>
app.use(express.methodOverride());
app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
// intercept OPTIONS method
if ('OPTIONS' == req.method) {
res.send(200);
} else {
next();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment