当请求失败时,捕获异常并打印错误日志,避免程序中断
@@ -84,7 +84,10 @@ export const selectWorksStudent = (oid: string, cid: string): Promise<any> => {
* @returns Promise<any>
*/
export const getHTML = (url: string): Promise<any> => {
- return axios.get(`${url}`)
+ return axios.get(`${url}`).catch((error) => {
+ console.error('getHTML 请求失败:', error)
+ return null
+ })
}
/**