Javascript delay/wait/sleep

I haven't tested this, so it probably won't work out of the box, but I think this is the kind of thing you should be looking at:

async function delay(ms) {
  return new Promise(resolve => setTimeout(resolve, ms))
}

async function makeRequests(variant_ids) {
  for (i = 0; i < variant_ids.length; i++) {
    await delay(1000)
    await PriceChange.trigger({
      additionalScope: {
        variant_id: variant_ids[i],
      },
    })
  }
}
1 Like