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

91
Vistas
Take a return on a javascript async function

I am trying to get a response of my checkNewActivities, Here you have the function calling:

checkNewActivities(area.userId, action, async (err, result) => {
                      if(!err) {
                        console.log(result);
                      } else {
                        console.log("Fail on checkNewActivities");
                      }
                    });

and here you have the function inside:

const checkNewActivities = (userID, action) => {
    User.findById(userID, async (error, user) => {
        if (!error) {
            // Call the EPITECH API with user.intranetToken
            const response = await axios.get(
                `https://intra.epitech.eu/${user.intranetToken}/planning/load/?format=json`
            );
            const codeEvent = action.backup.lastCode;
            const result = response.data.filter(
                (element) =>
                    element.semester == action.additionalInfo.semester && parseInt(element.codeevent.substring(6, 12)) > (codeEvent ? codeEvent : 0)
            );

            if (result.length > 0){
                Actions.findByIdAndUpdate(action._id, {
                    "backup.lastCode": parseInt(result[result.length - 1].codeevent.substring(6, 12))
                    },
                    function (err, actionModified) {
                    console.log(err, actionModified)
                })
            }
            console.log("THIS IS RESULT:",result);
            return result
        }
    });
};

I will really want to take the return to process it out of the function.

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