feat: 增强N8N模板响应处理和错误处理
- 为N8nImageGenerateTemplate添加响应数据处理链 - 提取res.data.data作为实际结果 - 支持数组和单个对象结果 - 添加数据有效性验证 - 为N8nVideoGenerateTemplate添加相同的响应处理逻辑 - 改进错误处理,抛出具体的错误信息 - 统一API响应格式处理,提升数据处理的可靠性
This commit is contained in:
parent
457e69f46b
commit
a6ea36f11f
|
|
@ -17,6 +17,16 @@ export abstract class N8nImageGenerateTemplate extends ImageGenerateTemplate {
|
|||
"image_url": imageUrl
|
||||
}
|
||||
}
|
||||
}).then(res => res.data).then(res => {
|
||||
if (res.status) {
|
||||
const data = res.data?.data;
|
||||
if(!data) throw new Error(`结果有误`)
|
||||
if (Array.isArray(data)) {
|
||||
return data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
throw new Error(res.msg)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -48,6 +58,16 @@ export abstract class N8nVideoGenerateTemplate extends VideoGenerateTemplate {
|
|||
"aspect_ratio": this.aspectRatio
|
||||
}
|
||||
}
|
||||
}).then(res => res.data).then(res => {
|
||||
if (res.status) {
|
||||
const data = res.data?.data;
|
||||
if(!data) throw new Error(`结果有误`)
|
||||
if (Array.isArray(data)) {
|
||||
return data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
throw new Error(res.msg)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue