const p = document.getElementById("myPelement")
fetch('http://example.com/movies.json')
.then((response) => {
return response.json();
})
.then((data) => {
p.innerText = data
});
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)