I am confused about the use of the fetch() function in PyScript.
There seems to be two versions of that function:
- from the js module
- from the pyscript module
Only the first one seems to accept two arguments.
I want to include header informations like so:
request_options = {
"method": "GET",
"headers": { "charset": "UTF-8" }
}
url = "https://www.nanobooks23.de/material/schachclub2.json"
response = await fetch(
"https://corsproxy.io/?" + url,
request_options
)
This only works with the fetch() function from the js module.
Otherwise I'll receive an
TypeError: fetch() takes 1 positional argument but 2 were given
So, how can I include the headers when using the fetch() function from the pyscript module?
I am using PyScript version 2024.9.2