Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // sandwich.js
- function getCheese(msg) {
- return new Promise(function(resolve, reject) {
- setTimeout(function(){ resolve(`cheese from ${msg}`) }, 1000);
- })
- }
- exports.makeSandwich = async function() {
- return new Promise(function(resolve, reject) {
- let response = await getCheese("Walmart")
- resolve(`sandwich from ${response}`)
- })
- }
- t = require('./sandwich.js')
- async function eat() {
- let sandwich = await t.makeSandwich()
- console.log("ate", sandwich)
- }
- eat()
- let response = await getCheese("Walmart")
- ^^^^^^^^^
Add Comment
Please, Sign In to add comment