Sqlite ngCordova return blank


#1

I working with credential validation using ionic and angularjs, what i wanted is when user already logged in then go to member page, when there is request for http post/get/else i want to add http header request, i was success if not using sqlite but when i changed my code using sqlite (ngCordova plugin) i got error. it return blank with no informations in my Xcode log. here the code

//app.js

'use strict';

var db = null;
angular.module('logiseraApp', ['ionic','ngCordova'])
 .run(function($ionicPlatform, $cordovaSQLite) {

  $ionicPlatform.ready(function() {
    //SQLite database
    db = $cordovaSQLite.openDB("my.db", 1);
    //create tables
    db.transaction(function(tx) {
      //create session table
      tx.executeSql('CREATE TABLE IF NOT EXISTS session (id integer primary key, name varchar(50), value text)');

      }, function(e) {
        console.log("ERROR: " + e.message);
    });
  });
})

//this is my focus error
//i check if session is not empty
//and fetch user data then store to config.headers
//there is no error if i"m not using sqlite
.factory('authInterceptor', function($location, $q, $cordovaSQLite) {
   return {
     request: function(config) {
      config.headers = config.headers || {};

      var query = "SELECT value from session where name = ? limit 1";
      $cordovaSQLite.execute(db, query, ["userdata"]).then(function(res) {
          if(res.rows.length > 0){
              console.log("result length", res.rows.length);
              var userdata = JSON.parse(res.rows.item(0).value);
              //apache
              //config.headers.token_user_id = userdata.user_id;
              //nginx
              config.headers['Token-User-Id'] = userdata.user_id;
          }
      }, function (err) {
          console.error(err);
      });

      return config;
     }
   };
})

.config(function($stateProvider, $urlRouterProvider, $httpProvider) {
  $httpProvider.interceptors.push('authInterceptor');
});

Thank you,