function lookupRepresentative() {
var address = document.getElementById(‘address’).value;
var apiKey = ‘YOUR_API_KEY’;
var apiUrl = ‘API_ENDPOINT_HERE’; // Replace with the actual API endpoint
// Make a request to the API
fetch(`${apiUrl}?address=${address}&key=${apiKey}`)
.then(response => response.json())
.then(data => {
// Process the data and update the ‘result’ div
document.getElementById(‘result’).innerHTML = JSON.stringify(data, null, 2);
})
.catch(error => {
console.error(‘Error:’, error);
document.getElementById(‘result’).innerHTML = ‘Error fetching data.’;
});
}