smileydts / death-or-glory

0 stars 0 forks source link

Display main page first for Player 0 #17

Open smileydts opened 7 months ago

smileydts commented 7 months ago

Run /players call passing player_id. Get back list of players and display.

djpace14 commented 7 months ago

Screenshot 2024-02-13 115759

djpace14 commented 7 months ago

I tried to integrate the players api and got an error message in the console. Here is what copilot said about the error message. Do you have any idea about this?

smileydts commented 7 months ago

Huh. I have exactly that code in the server (which is Flask). Push your latest changes so I can pull them down and try myself tonight. If you're still working on it in the meantime, tell the copilot that app.py uses flask_cors just as it recommends, so what gives?

What's the error message that appears in the console?

smileydts commented 7 months ago

I documented the URL wrong: it's actually get_players. I fixed the call on the front end and the docs. Apparently that error message just means that something failed its "preflight" check, not necessarily that there was a problem with CORS. Bleh.

Anyway, the call will still fail because it's not getting the data it needs. In order to fix this, you'll have to pass the player_id that you got as a cookie as new data with second call. However, an important thing to know is that calls are by default asynchronous, meaning that it won't wait for the first call to return before issuing the second call. In other words, you have to explicitly tell it to wait so that it has the data it needs for the second call. Look at the async, and especially await, keywords for this.