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
Unable to use pyfetch with POST #962
Comments
Hmmm curious! Can you copy/paste the network error you're getting? Are you running |
For what it's worth, in general POST pyfetch does work. Here's a brief example with the reqres testing API (written for 2022.09.1) - it should just echo back the provided body parameters, plus a random ID and a timestamp. import json
import js
from pyodide.http import pyfetch
url = 'https://reqres.in/api/users'
headers = {"Content-Type": "application/json"}
body = json.dumps({"name": "Jeff", "project": "PyScript"})
response = await pyfetch(url, method='POST', headers=headers, body = body)
j = await response.json()
print(f"Result = {j}") //Result:
Result= {'name': 'Jeff', 'project': 'PyScript', 'id': '808', 'createdAt': '2022-11-19T01:47:38.113Z'} I can't see how this is significantly different from your code though, with the exception of the content and content type. |
Sure can!
For reference, this is the HTML with sensitive information removed:
|
This was not labeled as 3rd party or mainstream but it looks to me that's all it is ... closing as it's been years since the original issue, but feel free to re-open it if you think there's something we can do in here, thanks! |
I can't seem to get pyfetch to work with a POST request where the API is expecting specific data. Almost all iterations of my code result in a NetworkError with no clear reason why it failed.
The above will result in a network error. Even if I remove headers & and body I will get a network error. The code I posted works when using the requests module. But when porting over to use pyscript, it fails.
The text was updated successfully, but these errors were encountered: