add web handle fetch error

This commit is contained in:
2021-11-24 11:09:21 +08:00
parent 8a2c8dd8b2
commit e3de41fe07
5 changed files with 24 additions and 3 deletions

View File

@@ -10,8 +10,13 @@ function GetRandomFiles(props) {
fetch("/api/v1/get_random_files")
.then((response) => response.json())
.then((data) => {
setIsLoading(false);
setFiles(data.files);
})
.catch((error) => {
alert("get_random_files error: " + error);
})
.finally(() => {
setIsLoading(false);
});
}