Azuy's picture
Help me make a website for querying information about Americans
86fd306 verified
raw
history blame contribute delete
782 Bytes
// Initialize tooltips
document.addEventListener('DOMContentLoaded', function() {
// Initialize any tooltips if needed
});
// Function to fetch data from APIs
async function fetchData(endpoint) {
try {
const response = await fetch(endpoint);
if (!response.ok) throw new Error('Network response was not ok');
return await response.json();
} catch (error) {
console.error('Error fetching data:', error);
return null;
}
}
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});