I am writing a program using JavaScript that begins with generating a random array of strings. I wanted to use these strings in requests to an API (Scryfall), and then use the JSON sent back for other functions within the same program. So after running my initial few functions I want to end up with an array of objects pulled from the JSON located at the target API, to then be used throughout the rest of the script that is running.
The following is how I am requesting the data from the API:
fetch('https://api.scryfall.com/cards/named?exact=Lightning+Bolt')
.then(response => response.json())
.then(data => ***); //the *** is just a placeholder
let exteriorData = {};
From what I understand, I can only use the data I have requested within that chain of .then() following my fetch. Is there any way to copy the data
object to the exteriorData
object?
Thank you.