Send IP to Webhook
<script>
// Function to fetch IP address from an external service
function fetchIPAddress() {
fetch('https://api.ipify.org?format=json')
.then(response => response.json())
.then(data => {
const ipAddress = data.ip;
console.log(`IP Address: ${ipAddress}`);
// Once the IP is fetched, send it to the webhook
sendIPToWebhook(ipAddress);
})
.catch(error => console.error('Error fetching IP address:', error));
}
// Function to send the IP address to a webhook
function sendIPToWebhook(ipAddress) {
const webhookUrl = 'YOUR_WEBHOOK_URL'; // Replace with your webhook URL
fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ ip: ipAddress }),
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch((error) => console.error('Error:', error));
}
// Call the function to start the process
fetchIPAddress();
</script>
Last updated
Was this helpful?