Last active
July 12, 2023 18:44
-
-
Save willie-hung/9c5f8b47bf531821a646464452acb1e3 to your computer and use it in GitHub Desktop.
post_6
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
function fetchData(): Promise<string> { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
const data = "Here are some mock data 🤡"; | |
if (data) { | |
resolve(data); | |
} else { | |
reject("Data not found"); | |
} | |
}, 2000); | |
}); | |
} | |
fetchData() | |
.then((data) => { | |
console.log("Received data:", data); | |
}) | |
.catch((error) => { | |
console.error("Error:", error); | |
}); | |
// Output: Received data: Here are some mock data 🤡 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment