0

I tried to create an object with data which I get from the DB I work with.

con.connect(function(err) {
  if (err) throw err;
  con.query("SELECT * FROM customers", function (err, result, fields) {
    if (err) throw err;
    console.log(result);
//creating an obj with a class i created
  });
});

but I can`t return the object I created because it shows me it's undefined (it is returned to the "small" function I created in the brackets.

does someone have any idea of a solution for this problem?

  • What exactly is the problem? Where are you trying to return the result to? Why not just use it in the `query` callback? – Mureinik Dec 24 '21 at 20:10
  • I wrote those lines in a static method, and I tried to return the object from the method I wrote to an another. and how? – NotAHacker Dec 24 '21 at 20:15

0 Answers0