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

75
Vistas
Getting the result with the Promise keyword

I am using Dialogflow to pass the dateofbirth and convert it into ISO format using a particular function written in helperfile in webhook end.

I am trying to call a function in a helper file that converts the date of birth to ISO format and return the date in Javascript.

But it gives the result as Promise {2020-01-20:00:00:00} instead of the actual value.

The code in the helper file is given below:

const formatdob = async (df,globalParameter,dob) => {   //birthDate should be in mm/dd/yyyy format
    try {
                     
        console.log("globalParameter",globalParameter);
        let dob = df._request.queryResult.queryText //  Capturing the input from user  
        globalParameter["dob"]=dob;                                          
        if(dob.length!=0){    //function to convert into a ISO format                                        
            const d = new Date(dob);    
            return Date(
                Date.UTC(
                d.getFullYear(),
                d.getMonth(),
                d.getDate(),
                d.getHours(),
                d.getMinutes(),
                d.getSeconds()
                )
            
            ).toISOString();


 }
        }
      
    catch (err) {
        console.log(err)
        throw err;
    }


};

module.exports = formatdob;
    
               

I call the function using

dob= formatdob(df, globalParameter,dob);
console.log("dob",dob);

When I print the value,I get :

dob Promise { '2020-01-01T00:00:00.000Z' }

I want only the value to be printed.I am a beginner to Javascript . I also tried using await keyword while calling the function but it returned the same result...Could you please help me out with this?

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