UrlFetchApp.fetch executes synchronously and makes execution slow. Is it possible to convert UrlFetchApp into promise?
I have been thinking of this approach:
- Return
HTTPResponse.getContent()as a Promise and add all the urls into a queue. - Defer their execution till
getContent().then()is invoked. - When
getContent()of any of the urls is called, usefetchAllto get all results and clear the queue.
Do you see any problems with this approach?