Skip to content

Cant figure out how to use async #59

@oefterdal

Description

@oefterdal
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions