0
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)

getting output:

{
  channel: '#the_squad',
  username: 'test ETL Notification',
  text: Promise { <pending> },
  icon_emoji: ':bell:'
}

desired output:

{
  channel: '#the_squad',
  username: 'test ETL Notification',
  text: 200,
  icon_emoji: ':bell:'
}

How do i return the desired output/ deal with the promise? The function is already async so im not sure where im going wrong. ps im new to js

0 Answers0