+ 1

Nodejs Mysql [object object] error and i cant insert any data on my database

I create a register page , when i insert all the fields and i submit a message appears on top the form "[object object]" and no data is added on the database The code : if(check){ reject(`This email " ${user.email}"Has already exist.Please choose an other email`); }else{ //hash the user password let salt =bcryptjs.genSaltSync(10); let data = { fullName: user.fullName, email: user.email, password: bcryptjs.hashSync(user.password, salt) } connection.query("INSERT INTO users set ? ", data, function(error,rows){ if(error){ reject(error); } resolve("Create a new user successfully"); }) } } catch (e) { reject(e); } });

21st Feb 2021, 12:18 AM
ABDELMOUGHIT GARDAM
ABDELMOUGHIT GARDAM  - avatar
3 Antworten
+ 2
This is my code if you can help me https://github.com/ABDEL-MORPHO/firstnodejs
21st Feb 2021, 3:44 PM
ABDELMOUGHIT GARDAM
ABDELMOUGHIT GARDAM  - avatar
+ 1
you may try to debug your code . 1. make sure the connection is established 2. try inserting any value to the database
21st Feb 2021, 1:40 AM
Hima
Hima - avatar
+ 1
the connection is etablished and every data inserted in the database is correct. the problem is when i try the insert data from the register form nothing is added on the database
21st Feb 2021, 11:21 AM
ABDELMOUGHIT GARDAM
ABDELMOUGHIT GARDAM  - avatar