Add error handling to emotes fetch call
This commit is contained in:
@@ -57,7 +57,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetch('/json')
|
fetch('/json')
|
||||||
.then(function(r){ return r.json(); })
|
.then(function(r){
|
||||||
|
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||||
|
return r.json();
|
||||||
|
})
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
var grid = document.getElementById('grid');
|
var grid = document.getElementById('grid');
|
||||||
var emotes = data.emotes || [];
|
var emotes = data.emotes || [];
|
||||||
@@ -83,6 +86,11 @@
|
|||||||
card.appendChild(span);
|
card.appendChild(span);
|
||||||
grid.appendChild(card);
|
grid.appendChild(card);
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch(function(err){
|
||||||
|
var grid = document.getElementById('grid');
|
||||||
|
grid.textContent = 'Failed to load emotes: ' + err.message;
|
||||||
|
grid.style.color = '#f66';
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user