#Promise
var p = new Promise((res,rej)=>{
const value = 'value of request'
setTimeout(function(){
res(value)
},3000)
}
)
p.then(function(data){console.log(`request done with ${data}`)})
#async
function timeout(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
async function asyncPrint(value, ms) {
await timeout(ms);
console.log(value);
}
asyncPrint('hello world', 3000);