help icon indicating copy to clipboard operation
help copied to clipboard

Error: Function not implemented.

Open juanchehin opened this issue 4 years ago • 2 comments

Details

Hello, I am trying to call my function sendMailConfirmation(), but nevertheless I am getting this error of "Error: Function not implemented."

nodej1

Node.js version

18.12.0

Example code

// ==================================================
//        Inserta un cliente
// ==================================================
public async altaCliente(req: Request, res: Response) {

    var Email = req.body[0];
    var Password = req.body[1];
    var Apellidos = req.body[2];
    var Nombres = req.body[3];
    
    const saltRounds = 10;  //  Data processing speed

    bcrypt.genSalt(saltRounds, function(err: any, salt: any) {
        bcrypt.hash(Password, salt, function(err: any, hash: any) {
            
            pool.query(`call bsp_alta_cliente('${Apellidos}','${Nombres}','${hash}','${Email}')`, function(err: any, result: any, fields: any){
                
                if(err){
                    res.status(404).json({ text: "Ocurrio un problema" });
                    return;
                }
                
                if(result[0][0].Mensaje === 'La persona ya se encuentra cargada'){
                    return res.json({
                        Mensaje: result[0][0].Mensaje,
                        pIdPersona: result[1][0].IdPersona
                    });
                }                
            
                console.log("pasa linea 68 : ",result[0]);

                if(result[0][0].Mensaje !== 'Ok'){
                    return res.json({
                        ok: false,
                        Mensaje: result[0][0].Mensaje
                    });
                }
                return res.json({ Mensaje: 'Ok' });
            })

            console.log("pasa antes enviar mail");
            enviarMailConfirmacion('[email protected]'); // <--------- Here!
        });
    });

    

}

// ==================================================
//   
// ==================================================

public async enviarMailConfirmacion(pEmail: string) {
    console.log("pasa enviarMailConfirmacion")
  // Generate test SMTP service account from ethereal.email
  // Only needed if you don't have a real mail account for testing
  let testAccount = await nodemailer.createTestAccount();

  // create reusable transporter object using the default SMTP transport
  let transporter = nodemailer.createTransport({
    host: keys.mail.host,
    port: keys.mail.port,
    secure: false, // true for 465, false for other ports
    auth: {
      user: keys.mail.user, // generated ethereal user
      pass: keys.mail.pass, // generated ethereal password
    },
  });

  // send mail with defined transport object
  let info = await transporter.sendMail({
    from: '"Fred Foo 👻" <[email protected]>', // sender address
    to: pEmail, // list of receivers
    subject: "Hello ✔", // Subject line
    text: "Hello world?", // plain text body
    html: "<b>Hello world?</b>", // html body
  });

  console.log("Message sent: %s", info.messageId);
  // Message sent: <[email protected]>

  // Preview only available when sending through an Ethereal account
  console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
  // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}

Operating system

Windows 10 Home

Scope

Typescript compilation

Module and version

Not applicable.

juanchehin avatar Nov 19 '22 12:11 juanchehin

Hi! If you look at the stack trace, it seems that this is due to an error in your code, possibly a lack of implementation.

If this is an error with typescript, please report it to them.

avivkeller avatar May 04 '24 01:05 avivkeller

I just encountered this silly "error".

I was trying to import some function through code actions in my editor and I mistakenly executed Add missing function declaration 'x' from tsserver, which adds this function definition at the end of the file:

function x() {
	throw new Error("Function not implemented.");
}

It definitely can take you by surprise, so I thought to comment this for future reference.

Pytness avatar Jun 07 '24 11:06 Pytness