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