Created
August 6, 2015 00:57
-
-
Save zephraph/63f27370927bc9ccf3cd to your computer and use it in GitHub Desktop.
This file contains 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
// Builds out a request function with a default payload | |
function requestBuilder(api, settings) { | |
return function request(endpoint, payload) { | |
payload = $.extend(true, settings, payload || {}); | |
return $.ajax(api + endpoint, payload); | |
} | |
} | |
// -- Imgur Module ---------------------------------------- | |
var imgur = (function() { | |
var api = 'https://api.imgur.com/3'; | |
var randomEndpoint = '/gallery/random/random'; | |
var request = requestBuilder(api, { | |
headers: { | |
Authorization: 'Client-ID 44099d515f0aac2' | |
} | |
}); | |
// link, title, account_url | |
return { | |
getRandomImages: function() { | |
return request('/gallery/random/random'); | |
} | |
} | |
})(); | |
// -------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment