Skip to content

Stagger Requests #41

Open
Open
@KevinHaeusler

Description

Is there a way to stagger requests correctly? For example I have 140 total requests in my google sheet and I want to only do 14 requests/s

Would something like this work?

Utilities.sleep(waitTime);


function do_fetch_(url, params) {
  if (params['contentType'] === "application/json" && typeof params['payload'] === 'object' ) {
     params['payload'] = JSON.stringify(params['payload'])
  }

const waitTime = Math.floor(Math.random() * 10);
Utilities.sleep(waitTime);
  
  var response = UrlFetchApp.fetch(url, params)
  return JSON.parse(response.getContentText());
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions