Skip to content

Commit

Permalink
fix: 修复 mockReponse 没有 headers 时的报错 Close: baidu#9565 (baidu#9583)
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Feb 24, 2024
1 parent 58feb0b commit cb7a0f6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/amis-core/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion packages/amis-core/src/utils/attachmentAdpator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cb7a0f6

Please sign in to comment.