add error response handling
This commit is contained in:
parent
95c14c4e72
commit
a8158c73c8
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name ScoreSaber Utils
|
// @name ScoreSaber Utils
|
||||||
// @namespace https://ssu.fascinated.cc
|
// @namespace https://ssu.fascinated.cc
|
||||||
// @version 1.0.6
|
// @version 1.0.7
|
||||||
// @description Useful additions to ScoreSaber!
|
// @description Useful additions to ScoreSaber!
|
||||||
// @author Fascinated
|
// @author Fascinated
|
||||||
// @match https://scoresaber.com/*
|
// @match https://scoresaber.com/*
|
||||||
@ -20,6 +20,11 @@
|
|||||||
*/
|
*/
|
||||||
async function fetchData(url) {
|
async function fetchData(url) {
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Failed to fetch data: ${response.status} ${response.statusText}`);
|
||||||
|
}
|
||||||
|
|
||||||
return await response.json();
|
return await response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +89,7 @@ async function loadPlayerData(path) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const playerData = await fetchData(`https://ssu.fascinated.cc/account/${playerId}`);
|
const playerData = await fetchData(`https://ssu.fascinated.cc/account/${playerId}`);
|
||||||
|
|
||||||
addStat(
|
addStat(
|
||||||
".stats-container",
|
".stats-container",
|
||||||
"+1 PP",
|
"+1 PP",
|
||||||
|
Loading…
Reference in New Issue
Block a user