Skip to content

Instantly share code, notes, and snippets.

@pedroborges
Created July 15, 2020 20:04
Show Gist options
  • Save pedroborges/f8968c2a55eaaa0b68ce927d3662323c to your computer and use it in GitHub Desktop.
Save pedroborges/f8968c2a55eaaa0b68ce927d3662323c to your computer and use it in GitHub Desktop.
Ways to fake API request delay during development
const wait = (delay, data) => ({ then(resolve) { setTimeout(resolve, delay, data) } })
const fakeApi = async () => await wait(500, [1, 2, 3, 4])
const wait = (delay, data) => new Promise((resolve) => setTimeout(resolve, delay, data))
const fakeApi = async () => await wait(500, [1, 2, 3, 4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment