环境变量修改
This commit is contained in:
@@ -20,8 +20,17 @@ class WorkListAPI {
|
||||
const response = await fetch(url, config);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => ({}));
|
||||
throw new Error(errorData.error || `HTTP错误: ${response.status}`);
|
||||
// 尝试解析错误响应
|
||||
let errorMessage = `HTTP错误: ${response.status}`;
|
||||
try {
|
||||
const errorData = await response.json();
|
||||
// 使用后端返回的详细错误信息
|
||||
errorMessage = errorData.detail || errorData.error || errorMessage;
|
||||
} catch (parseError) {
|
||||
// 如果无法解析JSON,使用默认错误消息
|
||||
console.error('无法解析错误响应:', parseError);
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
|
||||
Reference in New Issue
Block a user