0

i'm trying to return a boolean 0 or 1 but doesn't work.

How can i do that?

    checkKitReference(req, res)
  {
    var ref = req.params.ref;
    console.log("SELECT ref FROM st WHERE ref="+ref);
    request.query("SELECT ref FROM st WHERE ref='"+ref+"'",(err, records) => {
      console.log(err);
      if(records !== '')
      {
        return 0;
      }
      else
      {
        return 1;
      }
    });
  }

Thank you.

user3242861
  • 1,839
  • 12
  • 48
  • 93
  • You'll have to add a callback function to your function. Then you call such callback with the value `0` or `1`. – acdcjunior Jan 16 '17 at 23:15
  • So you want to return a response of "0" or "1" to the browser? Btw, "boolean" usually means "true" or "false", even if internally in some languages they are stored as 0 and 1 values. – GregL Jan 16 '17 at 23:15
  • `0` and `1` are numbers, not booleans (which are `true` and `false`) … but you're problem here is that you are trying to return from an asynchronous function. – Quentin Jan 16 '17 at 23:18

0 Answers0