Handle errors from the stats API
Prevents the UI from breaking when the stats API responds with an error.
@@ -152,7 +152,11 @@ export function getStats(origin: string) {
return new Promise((resolve, reject) => {
fetch(url)
.then(response => {
+ if (response.ok) {
response.json().then(data => resolve(data));
+ } else {
+ reject(new Error(response.statusText));
+ }
})
.catch(error => reject(error));
});
