Open yionr opened 1 year ago
根据官方文档:https://help.aliyun.com/document_detail/383987.html 我发现调用await client.list(); 时,console报错error: %j TypeError: Cannot read properties of null (reading 'Contents') 对应在项目源码中lib/browser/object.js:186的位置:
await client.list();
error: %j TypeError: Cannot read properties of null (reading 'Contents')
lib/browser/object.js:186
const result = await this.request(params); let objects = result.data.Contents || [];
我看了一下开发控制台中的响应数据是包含我需要的数据的(XML格式),但是不知道为什么似乎代码内没有将XML顺利转成JSON,导致后续result.data是null。 为了一开始方便, 我并没有使用STS,而是直接建立了一个RAM,不知道这是否会有影响?最后附上我完整的代码:
result.data
const client = new OSS({ region: '-', accessKeyId: '-', accessKeySecret: '-', bucket: '-' }) export const listDir = async () => { try { await client.list() } catch (e) { console.log(e); } } listDir()
我也碰到同样的问题了,楼主解决了吗
根据官方文档:https://help.aliyun.com/document_detail/383987.html 我发现调用
await client.list();
时,console报错error: %j TypeError: Cannot read properties of null (reading 'Contents')
对应在项目源码中lib/browser/object.js:186
的位置:我看了一下开发控制台中的响应数据是包含我需要的数据的(XML格式),但是不知道为什么似乎代码内没有将XML顺利转成JSON,导致后续
result.data
是null。 为了一开始方便, 我并没有使用STS,而是直接建立了一个RAM,不知道这是否会有影响?最后附上我完整的代码: