Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const BUTTON = document.querySelector('#button-1');
  2.  
  3. BUTTON.addEventListener('click', handleClick);
  4.  
  5. function handleClick(event) {
  6.     console.dir(event);
  7.  
  8.     fetch('https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1')
  9.     .then(takeCareOfResponseAndExtractJSON)
  10.     .then(showCardOnPage)
  11. }
  12.  
  13. function takeCareOfResponseAndExtractJSON(response) {
  14.     return response.json();
  15. }
  16.  
  17. function showCardOnPage(theJSONpartOfTheResponse) {
  18.     console.dir(theJSONpartOfTheResponse);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement