I’d like to ask for advice on how to get and post data using an API (Django REST framework). I have a hosted JSON file with hi-scores and names and I’d like to be able to get those scores and show them in a hi-score scene in my game, as well as post a score to it, if a player has made the leaderboard.
I’ve made something similar in Phaser 2 using xhr, is it much different in Phaser 3?
Thank you for the link.
My implementation is similar, though I had some issues with requests being asynchronous, but I fixed it I will probably be posting my game for review when it’s finished, so people can see how I did it
The best way to deal with an async xhr request is often to show some kind of loading screen until you receive the data. So say somebody goes to the scene with the high score table. It loads with a “Loading…” icon showing and at the same time you make the xhr request, use fetch() or whatever other way you want to make the API call. Once you receive data response, you update what you are showing to load in the high scores.