arrow_back Back to Notebook
google/google_apps_script
google/google_apps_script
April 15, 2019

Use promises in Google Apps Scripts

To use the latest es6 Promises in google app scripts it is very trivial to do so.

You need to include the Promises in the polyfill

Including Promises

Include the following code at the top of your file which you wish to use promises in.

var Promise,
    setTimeout = setTimeout || function (func,ms) {
      Utilities.sleep(ms);
      func();
    };

(function () {  

  // get the polyfill and eval
  if (!Promise) {
    var result = UrlFetchApp.fetch('https://cdnjs.cloudflare.com/ajax/libs/es6-promise/3.2.1/es6-promise.min.js');
    eval (result.getContentText());

    // add done for compatibility with other promise systems
    Promise.prototype.done = Promise.prototype.done || Promise.prototype.then ;

  }

}());

Thanks for reading!

John Wiseman

Full-Stack Software Engineer building scalable digital solutions. specializing in modern web technologies and mission-critical systems.

© 2026 Wiseman Systems Pty. Ltd.

Navigation

Start a Conversation

Ready to discuss your next project? Let's build something extraordinary together.

Get in Touch