I want to return the response of axios but get the console.log as undefined.
getFirstPageData();
async function getFirstPageData() {
const res = await getPageData(1) ;
console.log("res--->", res);
}
async function getPageData(page_num){
let pageNum = page_num;
console.log("page_num" , pageNum);
let path = "https://......"
axios.get(path).then(
(response) => {
var result = response.data;
console.log(result);
return result;
},
(error) => {
console.log(error);
}
);
}
Is this a problem in await or async. any way returning this response.