Fetching JSON game data
Last updated
Last updated
Here is an example of how you could use the fetch
function to retrieve data from API and log the enemies:
This code makes an HTTP GET request to the https://6away.org/adventure.json
API, which returns a JSON object containing data for a role-playing adventure game. The object is then parsed and the enemies
array is logged to the console.
You can also use the .then()
method to handle the response, like this: