Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nodejs promise async

// server.js
 
function square(x) {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(Math.pow(x, 2));
    }, 2000);
  });
}
 
async function layer(x)
{
  const value = await square(x);
  console.log(value);
}
 
layer(10);
Source by frugalisminds.com #
 
PREVIOUS NEXT
Tagged: #nodejs #promise #async
ADD COMMENT
Topic
Name
3+4 =