Fetch High Scores
Explore how to fetch high scores asynchronously by using JavaScript's async functions and fetching from a JSON file served by a local web server. Understand the process of transitioning from local storage to server-based data retrieval in game development.
We'll cover the following...
Now that we have created our high scores locally in the browser, we can look at how to make a high score list open for all. For this, we need to move the scores from our computer to a server somewhere where they can be accessed.
For testing purposes, it’s often a good idea to start by making the data available locally. We can do this by creating a JSON file with the data. Since we can use fetch to get the data from the JSON, just like we would do with a remote call, it will be easy to replace the URL from local to remote.
We can’t use fetch directly on the file system, so we ...