Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

441
Vistas
JS - Function returning undefined object while using axios. Log before return is an object, log after return is undefined

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

Console output

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.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda