0

I want to return my 'result' variable to the main function (geometryFromDatabase) but I have no idea how to do it. I have function like following:

function geometryFromDatabase() {
  var db = $window.sqlitePlugin.openDatabase({name:sqlite}, function () {
    db.transaction(function (tx) {
      tx.executeSql("select st_asText(geo_coord_) from referenzfb where id=676919;", [], function (tx, result) {
        return result;
      });
    });
  });
}
Alessio
  • 3,404
  • 19
  • 35
  • 48
  • 1
    Additionally/alternatively, depending on exactly where/how you want to use `result`, also see [Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](http://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron) – James Thorpe Jul 04 '16 at 13:23
  • The reason why your main function isn't returning the result is because you're for one running async code and two, you're returning result in a different execution context. If you want, I can show you how to handle that via promises (cleanest way) – Cheng Sieu Ly Feb 17 '17 at 15:22

0 Answers0