Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
({
getGiphyImage : function( emotion, callback ) {
var xhr = new XMLHttpRequest();
xhr.open( "GET", "https://api.giphy.com/v1/gifs/search?api_key=B9pfrx9wtMXmdLnVaJ6vllAW7uTqaHvO&q=" + emotion + "&limit=1", false )
xhr.onreadystatechange = function() {
if( this.readyState === 4 ) {
var jsonResp = JSON.parse( this.response );
var gifUrl = jsonResp.data[0].images.downsized.url;
callback( gifUrl );
}
};
xhr.send();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment