本地调试没问题,部署云端使用就出错了
云函数代码:
const CloudBase = require('@cloudbase/manager-node');
const { storage } = new CloudBase({ envId: '################' });
// 云函数入口函数
exports.main = async (event, context) => {
const keyword = event.keyword
const folderpath = 'FinalHousingData/'+keyword
console.log(keyword)
console.log(folderpath)
if(keyword === '')
{
return {
data:[
{
keyword: '',
data: [],
}
]
};
}else
{
try {
const res = await storage.listDirectoryFiles(folderpath);
console.log(res); // 云存储文件列表集合
return {
data:[
{
keyword: keyword,
data: res,
}
]
};
}
catch (err) {
console.error(err);
throw new Error('搜索失败');
}
}
};