Skip to content

Instantly share code, notes, and snippets.

@joemsak

joemsak/app.js

Created Dec 21, 2017
Embed
What would you like to do?
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