fetch-gifs
Version:
Promise Based GIF image fetcher
1 lines • 1.14 kB
JavaScript
;var giphy=function(e){return fetch("https://api.giphy.com/v1/gifs/search?q="+e+"&api_key=dc6zaTOxFJmzC&limit=50").then(function(e){return e.json()}).then(function(e){var i=e.data;return i.map(function(e){var i=e.images,r=i.fixed_height_small,t=i.fixed_height_small_still,n=i.fixed_height_downsampled,l=i.fixed_height_still,a=i.downsized_large,u=i.downsized_still;return{small:r.url,small_fixed:t.url,medium:n.url,medium_fixed:l.url,large:a.url,large_fixed:u.url}})})},riffsy=function(e){return fetch("https://api.riffsy.com/v1/search?key=LIVDSRZULELA&tag="+e).then(function(e){return e.json()}).then(function(e){var i=e.results;return i.map(function(e){var i=e.media[0],r=i.tinygif,t=i.nanogif,n=i.gif;return{small:t.url,small_fixed:t.preview,medium:r.url,medium_fixed:r.preview,large:n.url,large_fixed:n.preview}})})};module.exports=function(e){var i=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=i.offset,t=void 0===r?0:r,n=i.limit,l=void 0===n?30:n,a=giphy(e),u=riffsy(e);return Promise.all([a,u]).then(function(e){var i=e[0].concat(e[1]).slice(t,l);return Object.assign({},{data:i,more:i.length===l-t})})};