This is my code and I have been trying to understand why data is always promise pending.
const axios = require('axios');
const { resolve,reject } = require('bluebird');
async function getData() {
const test = await axios.get(`http://localhost:3000/admin/dashboarddata/tabledata`).then((response)=>{
return response
}).catch();
// console.log(test.data)
var val = test
return test;
}
const data = getData();
console.log(data)
You might be able to get the data by awaiting the function to resolve. Give the following a shot:
const data = await getData()
instead of: const data = getData()
Hope it helps!