Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

74
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda