Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JonEast87/cc197155777a1c235c9edfeccb85eb54 to your computer and use it in GitHub Desktop.
Save JonEast87/cc197155777a1c235c9edfeccb85eb54 to your computer and use it in GitHub Desktop.
Modern_asynchronous_programming_Async_and_await/src/main.js
const { welcome, goodbye, tell } = require("../utils/fortune-teller");
async function getFortune(question) {
try {
const response = await tell(question)
console.log(`Your question was: ${question}`);
console.log(`Your fortune is: ${response}`);
} catch (err) {
console.log(`There was an error: ${err}`);
}
}
async function fullSession(question) {
try {
console.log(await welcome())
await getFortune(question)
console.log(await goodbye())
} catch (err) {
console.log(`There was an error: ${err}`);
}
}
module.exports = { getFortune, fullSession };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment