Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions module1/01_fetch_image/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,27 @@ <h1>Fetch a Rainbow</h1>
<script>
console.log('about to fetch a rainbow');

catchRainbow()
.then(response => {
console.log('yay');
})
.catch(error => {
console.log('error!');
console.error(error);
});
catchRainbow();

// .then(response => {
// console.log('yay');
// })
// .catch(error => {
// console.log('error!');
// console.error(error);
// });

async function catchRainbow() {
const response = await fetch('rainbow.jpg');
try{
const response = await fetch('rainbow.jpg');
const blob = await response.blob();
document.getElementById('rainbow').src = URL.createObjectURL(blob);
console.log('yay');
}catch(error){
console.log('error!');
console.error(error);

}
}
</script>
</body>
Expand Down