hello, first time trying mongodb here. i get this error when i try to run register
this is my code
const name:string= params.get('name')?.toString()??""+ params.get('lname')?.toString??"";
const email:string= params.get('email')?.toString()??"";
const phone:string= params.get('phone')?.toString()??"";
const password:string= params.get('password')?.toString()??"";
const cpassword:string= params.get('cpassword')?.toString()??"";
if(password!=cpassword)
return;
let hashsalt;
await bcrypt.genSalt(10, (err:any, salt:string) => {
if (err) {
// Handle error
return;
}
hashsalt=salt;
});
let hash:string="";
await bcrypt.hash(password,hashsalt, (err:any, hashedpass:string) => {
if (err) {
// Handle error
return;
}
hash=hashedpass;
});
const client=await clientPromise;
const myDB = client.db("menu-manager");
const myColl = myDB.collection("users");
const user:User = {
user_id: uuidv4(),
name: name,
password: hash,
email: email,
phone: phone,
};
const result = await myColl.insertOne(user);
console.log(
`A document was inserted with the _id: ${result.insertedId}`,
);
authenticate(params)
}
i will post my client promise code below
