Why does this function not wait for the promise to be answered? How would a correct application of the async / await principles be?
My Code
var axios = require('axios');
var data = JSON.stringify({});
const getClient = async function () {
var config = {
method: 'get',
url: `https://reqbin.com/echo/get/json`,
headers: {
},
data : data
}
const res = await axios(config)
.then(function (response) {
console.log(response.data)
})
.catch(function (error) {
console.log(error);
})
return res
}
console.log(getClient())
TERMINAL
Promise { <pending> }
{ success: 'true' }