Skip to content

Instantly share code, notes, and snippets.

View ruffrey's full-sized avatar
🥦

ruffrey ruffrey

🥦
View GitHub Profile
@ruffrey
ruffrey / getty-image-search-example.js
Created December 15, 2015 16:02 — forked from anonymous/getty-image-search-example.js
Example of doing an image search on getty images and doing something with the first result
var API_KEY_NOT_SECRET = 'insert here';
var xhr = new XMLHttpRequest();
xhr.onload = function () {
console.log('response', JSON.parse(xhr.responseText));
var img = document.createElement('img');
img.src = JSON.parse(xhr.responseText).images[0].display_sizes[0].uri;
document.getElementsByTagName('body')[0].appendChild(img);
};
xhr.onerror = function (e) { console.error(e); };