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

126
Vistas
connect to server api page

ther by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). to terminate the node process on unhandled promise rejection, use the cli flag --unhandled-rejections=strict (see [

const router = require("express").Router();
const User = require("../modles/User");


router.get("/register", async (req,res) => {
   
    const user = await new User({
    username:"jhon",
       email:"jhon@gmail.com",
       password:"123456",
    
    
   })

   await user.save()
   res.send("ok")
   
});

module.exports = router;

]1 (rejection id: 1) (node:13400) [dep0018] deprecationwarning: unhandled promise rejections are deprecated. in the future, promise rejections that are not handled will terminate the node.js process with a non-zero exit code.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you only need a await and a catch. The first one is useless because you initialize your class.

So do that :

const router = require("express").Router();
const User = require("../modles/User");


router.get("/register", async (req,res) => {
   
    const user = new User({
    username:"jhon",
       email:"jhon@gmail.com",
       password:"123456",
   })

   await user.save().catch(e => e) // Return the errors in the void. You can console.log it.
   res.send("ok")
   
});

module.exports = router;
about 4 years ago · Juan Pablo Isaza Denunciar
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