msg = {
"channel": "#the_squad",
"username": "test ETL Notification",
"text": "",
"icon_emoji": ":bell:"
}
async function axiosTest(url) {
const response = await axios.get(url)
return response.status
}
let data = axiosTest(urlArray[0]);
data.then( async function(results){
return await results
})
msg.text = data
console.log(msg)
获取输出:
{
channel: '#the_squad',
username: 'test ETL Notification',
text: Promise { <pending> },
icon_emoji: ':bell:'
}
期望输出:
{
channel: '#the_squad',
username: 'test ETL Notification',
text: 200,
icon_emoji: ':bell:'
}
我如何返回所需的输出/处理承诺?该函数已经是异步的,所以我不确定我哪里出错了。 ps 我是 js 新手