title: Angular 2 how to return array of objects from nested promise
body: <p>I am trying to write an service to get the list of customers but i don't know to return the list of customers from nested promose.</p>
  
  <p>Please help me on this thanks in advance.</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { SQLite } from 'ionic-native';
  
  @Injectable()
  export class CustomerService {
      private sDBName:string;
      private db;
      private isDBExist:boolean = false;
  
      constructor() {}
  
      setDBName(sDBName:string) {
          this.sDBName = sDBName;
      }
  
      connect():Promise&lt;any&gt; {        
          this.db = new SQLite();
          return this.db.openDatabase({
              name: this.sDBName,
              location: 'default'
          });
      }
      getCustomersList():Promise&lt;any&gt; {
          return Promise.resolve(()=&gt;{            
              return this.connect().then(()=&gt;{                
                  this.isDBExist = true;
                  let sql = 'SELECT * FROM customer ORDER BY customer_id DESC LIMIT 10';
                  return this.db.executeSql(sql, {}).then((result)=&gt;{ 
                      let customers = [];             
                      for(let i=0; i&lt;result.rows.length; i++) {
                          customers.push(result.rows.item(i));
                      }
                      return customers;
                  },(err)=&gt;{
                      this.debug('Unable to select customers', err);
                      return [];
                  });
              },(err)=&gt;{
                  this.debug('Unable to open database', err);
                  return [];
              });
          });
      }
  }
  </code></pre>