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

128
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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