JSFiddle - React, Tailwind, and code Playground
by Haze32
HTML
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
JavaScript
// Define the function to make the API call
async function fetchData() {
try {
let url = "https://public-api.tracker.gg/v2/apex/standard/profile/psn/Daltoosh";
let options = {
method: "GET",
headers: {
"Content-Type": "application/json",
"TRN-API-Key": "6e336914-160a-4628-99b8-553f69614151"
}
};
let response = await fetch(url, options);
let json = await response.json();
console.log(json);
populateProfile(response.data.data);
} catch (error) {
console.error('There was an error fetching the data', error);
}
}
// Define the function to populate the profile
function populateProfile(data) {
// You can add logic here to populate the profile data.
// For this example, I'm just logging the data.
console.log(data);
}
// Call the fetchData function to initiate the API call
fetchData();