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

311
Vistas
Error de Bcrypt: se requieren argumentos de datos y sal

Estoy aprendiendo sobre NodeJS y estoy tratando de crear datos usando la secuencia de Postgres. pero tengo un error

 bcrypt UnhandledPromiseRejectionWarning: Error: data and salt arguments required.

Aquí está mi model user.js

 'use strict'; const { Model } = require('sequelize'); module.exports = (sequelize, DataTypes) => { class User extends Model { /** * Helper method for defining associations. * This method is not a part of the Sequelize lifecycle. * The `models/index` file will call this method automatically. */ static associate(models) { // define association here } }; User.init({ full_name: { type: DataTypes.STRING, allowNull: false, validate: { notEmpty: { msg: 'Nama tidak boleh kosong' } } }, email: { type: DataTypes.STRING, allowNull: false, validate: { isEmail: true, notEmpty: { msg: 'Email tidak boleh kosong' }, unique: { args: true, msg: 'Email address already in use!' } } }, username: { type: DataTypes.STRING, allowNull: false, validate: { notEmpty: { msg: 'Username tidak boleh kosong' } } }, password: { type: DataTypes.STRING, allowNull: false, validate: { notEmpty: { msg: 'Password tidak boleh kosong' } } }, profile_image_url: { type: DataTypes.STRING, allowNull: true, defaultValue: 'www.image.com', validate: { notEmpty: { msg: 'Url tidak boleh kosong' } } }, age: { type: DataTypes.INTEGER, allowNull: false, validate: { notEmpty: { msg: 'Umur tidak boleh kosong' } } }, phone_number: { type: DataTypes.STRING, allowNull: false, validate: { notEmpty: { msg: 'No telp tidak boleh kosong' } } } }, { sequelize, modelName: 'User', }); return User; };

He estado buscando respuestas de varias otras fuentes, pero aún no las he encontrado. Aquí está mi controller createUser.js .

 const { User } = require('../../models/user'); const bcrypt = require('bcrypt'); module.exports = async (req, res) => { const { full_name, email, username, password, age, phone_number } = req.body; const hash = await bcrypt.hash(password, 10); await User.create({ full_name, email, username, password: hash, age, phone_number }).then(success => { return res.status(201).json({ status: 'success', message: 'Success register', data: success }) }).catch(error => { return res.status(400).json({ status: 'error', message: error.message }); }); }
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