I have this in React:
const payload = {
x : x,
y : y
}
fetch("http://localhost:8080/update_game", {
method: "POST",
body: JSON.stringify(payload)})
And this in Python:
@post('/update_game')
def update_game():
req = request.json
print(req);
I keep getting:
None
127.0.0.1 - - [24/Jan/2022 14:06:36] "POST /update_game HTTP/1.1" 200 0
I don't see what I would be doing different than all of the other examples I've been finding. payload
successfully logs in the console. I have CORS set up and working correctly in Python. I also tried adding contentType: application/JSON
to the react side. I don't see what I could be doing wrong here.
edit for clarity: I'm attempting to print out the json response in the terminal on the python side. I simply want to see that this response is going through.
I discovered this little bit, that does show something, but is not correct:
@post('/update_game')
def update_game():
req = request.forms
print(dir(req))
print(dict(req))
print(req)
the ouput:
{'{"x":"0","y":"6"}': ''}
And I also have this:
def update_game():
req = request.headers['Content-Type']
# print(dir(req))
# print(dict(req))
print(req)
output:
text/plain;charset=UTF-8
I'm pretty sure that should be application/JSON