Skip to content

Instantly share code, notes, and snippets.

@rezonn
Last active January 28, 2021 04:49
Show Gist options
  • Save rezonn/71a1c73f4e981589c36ccd759aa2420d to your computer and use it in GitHub Desktop.
Save rezonn/71a1c73f4e981589c36ccd759aa2420d to your computer and use it in GitHub Desktop.
Google Apps Script polyfills
function fetch(url,options2) {
if (options2) {
if (options2.body) {
options2.payload = options2.body.toString("binary");
options2.body = undefined;
}
}
return new Promise(function (resolve, reject) {
try {
var data = UrlFetchApp.fetch(url, options2);
} catch(e) {console.log(e.message)}
resolve({
headers:data.headers,
text:function(){return data.getContentText()}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment