Provide a way to provide json data directly
This commit is contained in:
parent
06b2752732
commit
80772d9374
|
@ -72,7 +72,7 @@ query ($name: String) {
|
|||
url = "https://graphql.anilist.co"
|
||||
payload = {"query": query, "variables": {"name": username}}
|
||||
|
||||
response = await request(url, method="POST", payload=payload)
|
||||
response = await request(url, method="POST", json_data=payload)
|
||||
# Anilist API is broken and doesn't filter correctly, guess we have to do that ourselves
|
||||
data = []
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ async def request(
|
|||
*,
|
||||
headers=None,
|
||||
payload=None,
|
||||
json_data=None,
|
||||
method="GET",
|
||||
attr="json",
|
||||
force_content_type_json=False,
|
||||
|
@ -45,7 +46,9 @@ async def request(
|
|||
# Create the session with our headeres
|
||||
async with aiohttp.ClientSession(headers=headers) as session:
|
||||
# Make the request, based on the method, url, and paramaters given
|
||||
async with session.request(method, url, params=payload) as response:
|
||||
async with session.request(
|
||||
method, url, params=payload, json=json_data
|
||||
) as response:
|
||||
# If the request wasn't successful, re-attempt
|
||||
if response.status != 200:
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue