Skip to content

Instantly share code, notes, and snippets.

@feifanzhou
Created March 26, 2018 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feifanzhou/04184f01b54a9b40a1f4bf68b9a83869 to your computer and use it in GitHub Desktop.
Save feifanzhou/04184f01b54a9b40a1f4bf68b9a83869 to your computer and use it in GitHub Desktop.
Network request examples
// Stub a network request
new Promise((resolve, reject) => {
const dummyUser = {
name: 'Test User',
birthdate: '2001-01-01',
address: '3547 23rd St'
};
const waitTime = Math.random() * 2 + 3; // Between 3–5 seconds
setTimeout(() => resolve(dummyUser), waitTime);
});
// A real network request
request.get(true, usersShowPath(user.id));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment