Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
I tried hashing the password but getting the error

Error: data and salt arguments required at Object.hash (D:\social-media\rest-api\node_modules\bcrypt\bcrypt.js:137:17) at D:\social-media\rest-api\node_modules\bcrypt\promises.js:29:12 at new Promise () at Object.module.exports.promise (D:\social-media\rest-api\node_modules\bcrypt\promises.js:20:12) at Object.hash (D:\social-media\rest-api\node_modules\bcrypt\bcrypt.js:133:25) at D:\social-media\rest-api\routes\auth.js:8:45

const router = require("express").Router();
const User = require("../models/Users");
const bcrypt = require("bcrypt");

router.post("/register", async (req, res) => {
    try {
        const salt = await bcrypt.genSalt(10);
        const hashedPassword = await bcrypt.hash(req.body.password, salt);

        const newUser = new User({
            username: req.body.username,
            email: req.body.email,
            password: hashedPassword
        });
        const user = await newUser.save();
        res.status(200).json(user);
    } catch (err) {
        console.log(err)
    }
});

router.get("/register", (req, res) => {
    res.send("runing");
});

module.exports = router;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

How about only use const in bcypt.hash

const hashedPassword = await bcrypt.hash(req.body.password, 10)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!