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"
|
url = "https://graphql.anilist.co"
|
||||||
payload = {"query": query, "variables": {"name": username}}
|
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
|
# Anilist API is broken and doesn't filter correctly, guess we have to do that ourselves
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ async def request(
|
||||||
*,
|
*,
|
||||||
headers=None,
|
headers=None,
|
||||||
payload=None,
|
payload=None,
|
||||||
|
json_data=None,
|
||||||
method="GET",
|
method="GET",
|
||||||
attr="json",
|
attr="json",
|
||||||
force_content_type_json=False,
|
force_content_type_json=False,
|
||||||
|
@ -45,7 +46,9 @@ async def request(
|
||||||
# Create the session with our headeres
|
# Create the session with our headeres
|
||||||
async with aiohttp.ClientSession(headers=headers) as session:
|
async with aiohttp.ClientSession(headers=headers) as session:
|
||||||
# Make the request, based on the method, url, and paramaters given
|
# 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 the request wasn't successful, re-attempt
|
||||||
if response.status != 200:
|
if response.status != 200:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue