Guest User

Untitled

a guest
Jan 19th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. // sandwich.js
  2. function getCheese(msg) {
  3. return new Promise(function(resolve, reject) {
  4. setTimeout(function(){ resolve(`cheese from ${msg}`) }, 1000);
  5. })
  6. }
  7.  
  8. exports.makeSandwich = async function() {
  9. return new Promise(function(resolve, reject) {
  10. let response = await getCheese("Walmart")
  11. resolve(`sandwich from ${response}`)
  12. })
  13. }
  14.  
  15. t = require('./sandwich.js')
  16.  
  17. async function eat() {
  18. let sandwich = await t.makeSandwich()
  19. console.log("ate", sandwich)
  20. }
  21.  
  22. eat()
  23.  
  24. let response = await getCheese("Walmart")
  25. ^^^^^^^^^
Add Comment
Please, Sign In to add comment