【发布时间】:2021-09-13 06:46:55
【问题描述】:
我写了这段代码
const link = "CKV0nSlxV8M"
const rendertest = async (link) => {
const format = await ytdl(link, { quality: '22'})
let test = JSON.stringify(format[0].url)
alert(test) //string type
return test
}
let finalValue = rendertest(link)
console.log(finalValue)
我从test(字符串)得到这个值
但考试值不是String(对象)
我不知道我写错了哪一部分。我想要相同的test 和finalValue 的输出
【问题讨论】:
-
rendertest是一个async函数,你不会在这里等待它:let finalValue = rendertest(link)所以记录的finalValue"[object Object]" 是Promise。 -
感谢您告诉我确切的原因! @DrewReese
标签: reactjs react-native ytdl