From 918215759701d34db098265ca3e2b560f97c7195 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 21 Jul 2022 09:50:36 -0400 Subject: [PATCH] catch some js network errors --- common/static/js/mastodon.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/static/js/mastodon.js b/common/static/js/mastodon.js index 1f18435b..02a54679 100644 --- a/common/static/js/mastodon.js +++ b/common/static/js/mastodon.js @@ -56,8 +56,9 @@ const NUMBER_PER_REQUEST = 20 // ] async function getFollowers(id, mastodonURI, token, callback) { const url = mastodonURI + API_FOLLOWERS.replace(":id", id); + var response; try { - const response = await fetch(url+'?limit='+NUMBER_PER_REQUEST, {headers: {'Authorization': 'Bearer ' + token}}); + response = await fetch(url+'?limit='+NUMBER_PER_REQUEST, {headers: {'Authorization': 'Bearer ' + token}}); } catch (e) { console.error('loading followers failed.'); return; @@ -78,8 +79,9 @@ async function getFollowers(id, mastodonURI, token, callback) { async function getFollowing(id, mastodonURI, token, callback) { const url = mastodonURI + API_FOLLOWING.replace(":id", id); + var response; try { - const response = await fetch(url+'?limit='+NUMBER_PER_REQUEST, {headers: {'Authorization': 'Bearer ' + token}}); + response = await fetch(url+'?limit='+NUMBER_PER_REQUEST, {headers: {'Authorization': 'Bearer ' + token}}); } catch (e) { console.error('loading following failed.'); return;