Last active
September 27, 2017 19:19
-
-
Save obenland/f9ebc90b91dab71970e6cc265b791415 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var fetchGifs = _.debounce( function fetchGifs( search ) { | |
if ( attributes.fetching ) { | |
return; | |
} | |
props.setAttributes( { | |
fetching: true, | |
} ); | |
$.getJSON( 'https://api.giphy.com/v1/gifs/search?api_key=Fswo3IBHt0TViFMN6zYgbYzSEb3sLx7I&limit=10&offset=0&rating=G&lang=en&q=' + encodeURI( search ) ) | |
.success( function fetchSuccess( data ) { | |
props.setAttributes( { | |
fetching: false, | |
matches: data.data, | |
} ); | |
} ) | |
.fail( function fetchFail() { | |
props.setAttributes( { fetching: false } ); | |
} ); | |
}, 1000 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment