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

@@ -14,6 +14,9 @@ function FfmpegConfig(props) {
if (data.ffmpeg_config_list.length > 0) {
props.setSelectedFfmpegConfig(data.ffmpeg_config_list[0]);
}
})
.catch((error) => {
alert("get_ffmpeg_config_list error: " + error);
});
}, []);

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);
});
}

View File

@@ -32,9 +32,14 @@ function SearchFiles(props) {
})
.then((response) => response.json())
.then((data) => {
setIsLoading(false);
const files = data.files ? data.files : [];
setFiles(files);
})
.catch((error) => {
alert("get_files_in_folder error: " + error);
})
.finally(() => {
setIsLoading(false);
});
}

View File

@@ -27,7 +27,6 @@ function SearchFolders(props) {
})
.then((response) => response.json())
.then((data) => {
setIsLoading(false);
let folders;
if (data.folders) {
folders = data.folders;
@@ -35,6 +34,12 @@ function SearchFolders(props) {
folders = [];
}
setFolders(folders);
})
.catch((error) => {
alert("search_folders error: " + error);
})
.finally(() => {
setIsLoading(false);
});
}

View File

@@ -16,6 +16,9 @@ function Share(props) {
.then((response) => response.json())
.then((data) => {
setFile([data]);
})
.catch((error) => {
alert("get_file_info error: " + error);
});
}, [params]);
return (