async await vs then
async function fancyShowRainbow(){
const response = await fetch("rainbow.jpg");
const blob = await response.blob();
document.querySelector(".my-image").src = URL.createObjectURL(blob);
}
function showRainbow(){
fetch("rainbow.jpg")
.then(res => {
console.log(res);
return res.blob();
})
.then(blob => {
document.querySelector(".my-image").src = URL.createObjectURL(blob);
console.log(blob);
})
.catch(error => {
console.log("ERROR!!");
console.error(error);
});
}