scrimba
Frontend Career Path
Working with APIs
Async JS
War - save deckId for later use
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

War - save deckId for later use
AboutCommentsNotes
War - save deckId for later use
Expand for more info
index.js
run
preview
console
function handleClick() {
fetch("https://apis.scrimba.com/deckofcards/api/deck/new/shuffle/")
.then(res => res.json())
.then(data => console.log(data))
}

document.getElementById("new-deck").addEventListener("click", handleClick)
/**
* Challenge
*
* Background:
* The Deck of Cards API expects us to provide the deck id
* of the deck we're playing with so it can remember which
* cards we've already drawn, how many are remaining in the
* deck, etc.
*
* Task: save the deck_id from the returned data to a local
* variable so we can use it later
*/
Console
/index.html
-1:45