event.preventDefault();
$('#mainContent').empty();
$.ajax({
url: randomDrinksURL,
method: 'GET'
}).then(function (response) {
console.log(response);
var mainContent = $('#mainContent');
mainContent.append(`
<img src='${response.drinks[0].strDrinkThumb}'>
<p>${response.drinks[0].strDrink}</p>
<p>${response.drinks[0].strMeasure1} of ${response.drinks[0].strIngredient1}</p>
<p> ${response.drinks[0].strInstructions}</p>
`);
});
This data provides details for various ingredients and measurements from 1 to 15. I am currently exploring ways to iterate through them dynamically, ensuring it stops when a value is null.
I attempted to use a for loop but encountered difficulties. Any suggestions or guidance on this matter would be greatly appreciated!