Skip to content

Instantly share code, notes, and snippets.

@joemsak
Created December 21, 2017 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemsak/d12a962d73d27f15ad26405fe910eaa2 to your computer and use it in GitHub Desktop.
Save joemsak/d12a962d73d27f15ad26405fe910eaa2 to your computer and use it in GitHub Desktop.
var express = require('express');
var fetchUrl = require("fetch").fetchUrl;
var app = express();
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.get('/', function (req, res) {
fetchUrl(
"https://api.instagram.com/v1/users/self/media/recent/" +
"?access_token=***THAR BE DRAGONS***",
function(error, meta, body) {
if (!error && meta.status === 200) {
res.json(JSON.parse(body));
} else {
res.json(error);
}
}
);
});
var http = require('http');
var port = process.env.PORT || 3000;
app.set('port', port);
var server = http.createServer(app);
server.listen(port, function() {
console.log('Example app listening on port ' + port + '!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment