Last active
May 9, 2018 16:58
-
-
Save shrutis22/e1fc9d0830a88b1ad54c54197f0da677 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
({ | |
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