title: Resolve not called in a recursive promise function
body: <p>I've made a recursive function to implement <a href="https://developers.google.com/calendar/v3/sync" rel="nofollow noreferrer">incremental synchronization of  Google Calendar Events list</a> with their JavaScript API, and everything seems to work except the <code>resolve()</code>, and I dont understand why...</p>
  
  <p>What am I missing?</p>
  
  <pre><code>  syncEvents (calendarId) {
  
        let eventsItems = []
        let syncToken = null
        let pageToken = null
  
        function next(params) {
          return new Promise((resolve) =&gt; {
            gapi.client.calendar.events.list( params ).then( (response) =&gt; {
              syncToken = response.result.nextSyncToken;
              pageToken = response.result.nextPageToken;
  
              let items = response.result.items
              eventsItems.push(items)
  
              if (pageToken) {
                return next({
                  'calendarId': params.calendarId,
                  'pageToken': pageToken,
                  'syncToken': syncToken
                })
              }
              if (syncToken) {
                console.log('ok now resolve!') // &lt;= This is called...
                resolve(response)
              }
  
            })
          })
  
        }
  
        next({'calendarId': calendarId}).then( (result) =&gt; {
            console.log(eventsItems) // &lt;= And this is not called...
        })
  
    }
  </code></pre>
  
  <p>Thanks!</p>