diff --git a/packages/amis-core/src/utils/api.ts b/packages/amis-core/src/utils/api.ts index e3f7004b89c..9b30f158be2 100644 --- a/packages/amis-core/src/utils/api.ts +++ b/packages/amis-core/src/utils/api.ts @@ -368,7 +368,7 @@ export function responseAdaptor(ret: fetcherResult, api: ApiObject) { // 返回内容是 string,说明 content-type 不是 json,这时可能是返回了纯文本或 html if (typeof data === 'string') { - const contentType = (ret.headers as any)['content-type'] || ''; + const contentType = (ret.headers as any)?.['content-type'] || ''; // 如果是文本类型就尝试解析一下 if ( ret.headers && diff --git a/packages/amis-core/src/utils/attachmentAdpator.ts b/packages/amis-core/src/utils/attachmentAdpator.ts index 7146de15cdb..10a32363224 100644 --- a/packages/amis-core/src/utils/attachmentAdpator.ts +++ b/packages/amis-core/src/utils/attachmentAdpator.ts @@ -38,7 +38,7 @@ export function attachmentAdpator( } } - let type = response.headers['content-type']; + let type = response.headers?.['content-type']; let blob = response.data.toString() === '[object Blob]' ? response.data