SQLite Db Sync call back

I need to fetch data from local database and send that to server. Problem I am facing is, my post method is getting executed before success callback is completed in db.executeSq method. I need process to wait till it is completed.

 sql = "select * from muser" ;
 db.executeSql(sql,{})
      .then((data) => {
           console.log("Got data from DB");
       })
      .catch(e => console.log(e));

  console.log("End of Function");

This is rough form of my code. I expect output as:

O/P:
Got data from DB
End of Function

But I am getting output as:

O/P:
End of Function
Got data from DB

please help me.

If you want to do something after conpletion, put that code in the code block having the Got data console log

 it is not about output statement, here im talking about flow of control.

Because its asynchronous code. You need to put your code in the block of callback if you want waiting until finish

sql = "select * from muser" ;
 db.executeSql(sql,{})
      .then((data) => {
           console.log("Got data from DB");
Http.post(url, data);  // here send your data to your server. 
       })
      .catch(e => console.log(e))