Open Khansa03 opened 8 months ago
const existUsername = new Promise((resolve, reject) => {
UserModel.findOne({ username }, function (err, user) {
if (err) reject(new Error(err));
if (user) reject({ error: "Please use unique username" });
resolve();
});
});
Instead handle this with the code below by using the async await method
const existUsername = await UserModel.findOne({
username,
function(err, user) {
if (err) reject(new Error(err));
if (user) reject({ error: "Please use unique username" });
},
});
Hopefully this works for you. Thank me later
What do I do? it says could not register