fix(capcut): 增强API错误响应详情
在API返回错误时,添加完整的响应数据切片到错误信息中,方便调试时定位问题。最多保留300字符的JSON数据。
This commit is contained in:
@@ -40,7 +40,7 @@ async function api(endpoint, data = {}, timeout = 60000) {
|
||||
? await axios.get(url, { params: data, timeout })
|
||||
: await axios.post(url, data, { timeout })
|
||||
if (res.data.code !== undefined && res.data.code !== 0) {
|
||||
throw new Error(`API [${endpoint}] 返回错误: ${res.data.message}`)
|
||||
throw new Error(`API [${endpoint}] 返回错误: ${res.data.message} | detail: ${JSON.stringify(res.data).slice(0, 300)}`)
|
||||
}
|
||||
return res.data
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user