Answers for "# async await function"

31

async await

const data = async ()  => {
  const got = await fetch('https://jsonplaceholder.typicode.com/todos/1');
  
  console.log(await got.json())
}

data();
Posted by: Guest on July-24-2020
3

Async/Await

async function run () {
  const user = await getUser()
  const tweets = await getTweets(user)
  return [user, tweets]
}
Posted by: Guest on October-09-2021
0

# async await function

# async await function
import asyncio
import time
async def sleep_6():
  time.sleep(5)
  print('5 done')
  time.sleep(3)
  print('3 done')
  
async def sleep_8():
  await asyncio.sleep(7)
  print('8 done')

async def gather_fxn():
  await asyncio.gather(sleep_6(), sleep_8())

loop=asyncio.new_event_loop()
loop=loop.run_until_complete(gather_fxn())
loop.close()

# output:
# 5 done
# 3 done
# 8 done
Posted by: Guest on March-28-2022

Python Answers by Framework

Browse Popular Code Answers by Language