[BUG] Example not working
Opened this issue · 1 comments
datacubeR commented
Try HikerAPI SaaS with a free trial https://hikerapi.com/p/KhMxYMSn
Describe the bug
Running the README example simply just don't work.
To Reproduce
from aiograpi import Client
ACCOUNT_USERNAME = "myuser"
ACCOUNT_PASSWORD = "mypassword"
cl = Client()
await cl.login(ACCOUNT_USERNAME, ACCOUNT_PASSWORD)
user_id = await cl.user_id_from_username(ACCOUNT_USERNAME)
medias = await cl.user_medias(user_id, 20)
Traceback
Expected behavior
A working Script
Screenshots
Show above...
Desktop (please complete the following information):
- OS: Pop OS 22.04 LTS
- Python version 3.10
- aiograpi version 0.03
Additional context
I'm just getting familiar with the API so a more descriptive error would be very beneficial.
ajkessel commented
You need to do something like this, because async functionality needs to be in an async function:
import asyncio
import aiograpi
async def test():
ACCOUNT_USERNAME = "myuser"
ACCOUNT_PASSWORD = "mypassword"
cl = Client()
await cl.login(ACCOUNT_USERNAME, ACCOUNT_PASSWORD)
user_id = await cl.user_id_from_username(ACCOUNT_USERNAME)
medias = await cl.user_medias(user_id, 20)
async def main():
await test()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())