Skip to content

Commit

Permalink
Error mitigation on fetch requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexankitty committed Oct 20, 2022
1 parent a428ffc commit e855f95
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ChatboxBot.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js" defer></script>
<script src="js/js-yaml-bundle.js" defer></script>
<script src="https://github.com/tmijs/tmi.js/releases/download/v1.8.5/tmi.min.js" defer></script>
<script src="js/youtube-chat-bundle.js" defer></script>
<!--<script src="js/youtube-chat-bundle.js" defer></script>-->
<script src="js/twitchapi.js" defer></script>
<script src="js/tmi-emote-parse-bundle.js" defer></script>
<script src="js/cache.js" defer></script>
Expand Down
11 changes: 11 additions & 0 deletions js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,19 @@
if(settings.options.pfpCircle){
pfpImg.style.borderRadius = "50%";
}
try{
pfpImg.src = await getPFP(displayname);
nameNode.appendChild(pfpImg);
}
catch{
try{//retry just in case something silly happened
pfpImg.src = await getPFP(displayname);
nameNode.appendChild(pfpImg);
}
catch{
console.error(`Failed to load PFP for ${context['display-name']} continuing on without one.`)
}
}
}

/*
Expand Down
2 changes: 1 addition & 1 deletion js/twitchapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class API {
TwitchAPIEvents.emit('authorize');
}

static async fetch({url, responseHandler, paramobj = {}, headerobj = {}, method = "GET", mode = 'cors', cache = 'default', credentials = 'same-origin', redirect = 'follow', referrerpolicy = 'no-referrer-when-downgrade', urlencode = false, authorizing = false}) {//And so it begins
static async fetch({url, responseHandler, paramobj = {}, headerobj = {}, method = "GET", mode = 'cors', cache = 'default', credentials = 'omit', redirect = 'follow', referrerpolicy = 'no-referrer', urlencode = false, authorizing = false}) {//And so it begins
if (urlencode) {

headerobj['Content-Type'] = 'application/x-www-form-urlencoded';
Expand Down

0 comments on commit e855f95

Please sign in to comment.