简体   繁体   中英

google apps script with UrlfetchApp.fetchAll() or with async/ await for multiple http requests?

I created some projects in google apps script in the past for some automation, that also included some http-fetches. In the past, this worked with.fetch() pretty well, but now we need to fetch multiple urls. Since apps script now uses V8 runtime I considered to do so with promises. I'm also quite new to async/await and promises in general. So I considered to try the UrlfetchApp.fetch() within async functions, just to find out, that there's no difference in execution time.

I red, that UrlfetchApp.fetch() will always be sync, no matter whether you declare your function as async or not, due to the GAS-API-design. But I can't find detailed infos on this. Is this true?

If yes: Then the only way to fetch multiple urls would be UrlfetchApp.fetchAll(), right?

If no: Means simple.fetch() would work inside async funcs (and could be chained in Promise.all()) then I'd invest further time in this.

So, yes or no would help a lot here!

Thanks in advance!

Currently, Urlfetchapp runs synchronously and although the syntax of promises are supported, it works synchronously too.

Then the only way to fetch multiple urls would be UrlfetchApp.fetchAll(), right?

Yes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM