Created
November 30, 2022 10:09
-
-
Save Drag13/20b83773a25bbb3c15c7ef241595c692 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const data = { userName: "test user" }; | |
| const delay = 1200; | |
| const errorChance = 0.2; | |
| export function fetchData() { | |
| return new Promise((rs, rj) => { | |
| setTimeout( | |
| () => | |
| Math.random() > errorChance ? rs(data) : rj("Something went wrong"), | |
| delay | |
| ); | |
| }); | |
| } | |
| fetchData().then(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment