Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant figure out how to use async #59

Open
oefterdal opened this issue Sep 12, 2022 · 0 comments
Open

Cant figure out how to use async #59

oefterdal opened this issue Sep 12, 2022 · 0 comments

Comments

@oefterdal
Copy link

from settings import Settings
from jsonapi_client import Session, Filter, ResourceTuple, Modifier, Inclusion


headers = {'headers': {
    'Accept': 'application/vnd.api+json',
    'Authorization': f"Bearer {Settings().access_token}"}}
async with Session(server_url="https://api.example.com/", request_kwargs=headers, enable_async=True) as s:
    querystring = 'filter[created_at][path]=created_at&filter[created_at][value]=2022-08-01 00:00:00...2022-09-01 00:00:00&filter[created_at][operator]=between'
    include = Inclusion("order-totals,order-status,order-products")
    modifier = Modifier("page[size]=10&page[number]=1")
    filter = Filter(querystring)
    modifier_sum = filter + modifier + include


if __name__ == '__main__':
    async for r in s.iterate('orders'):
        print(r)

SyntaxError: 'async with' outside async function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant