Skip to content

Commit

Permalink
Update dm-template-handler.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ledangtrung committed Dec 11, 2024
1 parent bdbf2bb commit 7c67a36
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion js/dm-template-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,36 @@ function closeModal() {
modal.classList.remove("active");
}

document.addEventListener("DOMContentLoaded", fetchThumbnails);
document.addEventListener("DOMContentLoaded", fetchThumbnails);

// get mapKey
async function fetchGoogleMapsApiKey() {
const apiUrl = 'https://api.realtimex.co/v1/keys/google/maps';

// Set up request options
const requestOptions = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
// Uncomment the line below if you need to include an authorization token
// 'Authorization': `Bearer YOUR_ACCESS_TOKEN`
}
};

try {
const response = await fetch(apiUrl, requestOptions);

// Check if the response is ok (status in the range 200-299)
if (!response.ok) {
throw new Error(`Network response was not ok: ${response.status}`);
}

// Parse the JSON response
const data = await response.json();

return data.api_key; // Return the API key for further use
} catch (error) {
console.error('Fetch error:', error);
}
}

0 comments on commit 7c67a36

Please sign in to comment.