I have a function that is supposed to make AJAX requests with an event loop while taking 9 inputs at the top and querying them from a database. Currently, it only logs to the console but will eventually perform more actions. However, I am encountering an error of "undefined" and I'm unsure what the issue might be.
var cards = [
"Black Lotus",
"Mox Pearl",
"Mox Sapphire",
"Mox Jet",
"Mox Ruby",
"Mox Emerald",
"Time Walk",
"Timetwister",
"Ancestral Recall",
];
for (var i = 0; i < cards.length; i++) {
function renderBinder() {
var cardName = cards[i];
var queryURL = "https://api.scryfall.com/cards/named?fuzzy=" + cardName;
$.ajax({
url: queryURL,
method: "GET",
}).then(function (response) {
console.log(response.name);
});
}
}