1

I would like to be able to handle things like "email already taken" during registration queries. The only question addressing this that I've found is here

How can I fetch the warnings after node-mysql queries

and I haven't found it helpful.

Here's my query function

newMasterAcc(input, callback){
    let newQuery = {
      sql: "INSERT INTO masteracc SET ?",
      values: [input],
      callback: (error, results, fields) => {
        if(error){
          callback(false);
        }
        else{
          callback();
        }
      }
    }
    this.pool.query(newQuery);
  }
Abu Sufian
  • 991
  • 1
  • 6
  • 15
Cozy Gizmo
  • 33
  • 6
  • 1
    Why can't you just make a request to check if the email already in the table and based on that, you return a normal message indicates the error? – ROOT Mar 02 '20 at 18:35
  • I was just hoping I could do it at once instead of separate queries. Guess I'll try it out. – Cozy Gizmo Mar 02 '20 at 18:39
  • 1
    I figured that out, but that might not be secure, what if your app some reasons didn't catch the error, then your app might be in troubles, also errors and warnings consumes more resources anyway. – ROOT Mar 02 '20 at 18:43

0 Answers0