Advertisement
GabeLinux

Web - 3 - 9

Jan 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // https://github.com/Giphy/GiphyAPI
  2.  
  3. const body = document.querySelector('body')
  4.  
  5. fetch('http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&rating=pg')
  6.   .then((res) => res.json())
  7.   .then((data) => data.data)
  8.   .then((image) => {
  9.     let img = document.createElement('img')
  10.     img.src = image.image_original_url
  11.     img.style = 'display: block; margin: 0 auto; margin-top: 100px; border: 30px inset teal; border-radius: 10px;'
  12.     body.appendChild(img)
  13.   })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement