So I've got two functions. The first function calls the second. The console.log(listDogs) appears to show an object. the console.log(listDogs2) shows as undefined. The idea outcome is that the return from the function is the same as before.
async function listDogs() {
let listDogs2 = await getListDogs();
console.log(listDogs2);
}
async function getListDogs(){
await axios.get(`https://dog.ceo/api/breeds/list/all`)
.then(response => {
let listDogs = response.data.message;
console.log(listDogs);
return listDogs;
}).catch((err) => {
console.log(err);
});
}
Console Output
line 31 is console.log(listDogs);
line 7 is console.log(listDogs2);
Any help appreciated. Either a solution, or a pointer about where to read. Have done quite abit of searching and cannot get my head round it. Thanks in advance.