0

I have been working on a simple duplicate email submission, here it is:

   var filter = function (o) { // o.email query - already submitted query a@a.com

    return o.email === email; // passing a@a.com or awe@awe.com

   };

  db.one(filter, function(email) { // function not picking up callback

    if (email == null) {  //same - callback returns null 

        error.add('duplicate');
        self.json(error);
        return;

    }

    /....other code .../
});

How could I get the result of the callback?

Xdrone
  • 781
  • 1
  • 11
  • 21

1 Answers1

2

In the node.js world, callbacks have the convention of placing the first parameter as the error (err), and the second parameter as the data result (email).

db.one(filter, function(err, email) {
  console.log(email);
});
Wilson
  • 9,006
  • 3
  • 42
  • 46