Is it possible to write JavaScript code to make HTTP requests such that the the same code can be used on multiple runtimes, with a suitable utility library? In this case, it would be desirable if the code could work on node.js, Google App Script and as a Google Chrome extension or ChromeOS app.
The problem is that these different runtimes have different kinds of APIs and different capabilities to accomodate programming styles. App Script provides URLFetchApp, which is synchronous. Chrome and other browsers support XMLHttpRequst, which is asynchronous. Node.js supports both asynchronous and synchronous programming, and varying styles can be combined using fibers, for example. However, fibers are not supported on other runtimes. Google App Script, on the other hand, does not seem to support plugging in asynchronous code using async/await.
It seems that it is not possible to write code that supports all these runtimes without some kind of pre-processing the code.