fetch("https://www.thecocktaildb.com/api/json/v1/1/random.php")
.then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error("NETWORK RESPONSE ERROR");
}
})
.then(data => {
console.log(data);
displayCocktail(data)
})
.catch((error) => console.error("FETCH ERROR:", error));
Code language: JavaScript (javascript)