fetch('https://ipwho.is/?format=json')
.then(d => d.json())
.then(res => {
return fetch('/<your-php-script-address-here>', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify(res),
});
});
PHP:
$receivedIP = $_POST['ip'] ?? null;