when it comes to error handling, what's the best p...
# orm-help
p
when it comes to error handling, what's the best practice? This is what my code looks like right now.
Copy code
const createUser = (req, res, next) => {
    const { name, email, password } = req.body;
    bcrypt.hash(password, saltRounds, async function(err, hash){           
        if (err) { res.status(400).json(err); }
        try {
            let result = await prisma.user.create({
                data: {
                    name, 
                    email, 
                    password: hash
                }
            });
            res.status(200).json(result);
        } catch (e) {
            res.json(e);
        }
    });
}
r
@prgrmmr 👋 Yes this is fine. Using the Promise version of
bcrypt
with
async/await
will make it easier.