// 存储资源到本地
async save_upload_asset(ctx) {
const list = []
//获取post传递的数据
const { key, url } = ctx.request.body
// 保存数据到data目录中
ctx.body = await new Promise(res => {
list.push({ key, url })
fs.writeFile(require('../data/upload_asset.txt'), JSON.stringify(list), (err) => {
console.log(res)
res({
code: 0,
data: err ? false : true,
success: true
})
})
})
}
在fs.witeFile 的err 中报如下错误, 请问是什么原因啊
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of Object
已解决, writeFile 第一个参数必须是字符串路径