async await
const data = async () => {
const got = await fetch('https://jsonplaceholder.typicode.com/todos/1');
console.log(await got.json())
}
data();
async await
const data = async () => {
const got = await fetch('https://jsonplaceholder.typicode.com/todos/1');
console.log(await got.json())
}
data();
Async/Await
async function run () {
const user = await getUser()
const tweets = await getTweets(user)
return [user, tweets]
}
# 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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us