-
-
Save feifanzhou/04184f01b54a9b40a1f4bf68b9a83869 to your computer and use it in GitHub Desktop.
Network request examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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