Browse Source

fix(course): 捕获getHTML请求异常并返回null

当请求失败时,捕获异常并打印错误日志,避免程序中断
lsc 1 month ago
parent
commit
5fc74fa8ce
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/services/course.ts

+ 4 - 1
src/services/course.ts

@@ -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
+  })
 }
 
 /**