const getUserIP = async () => {
try {
const response = await fetch('https://api64.ipify.org?format=json');
const data = await response.json();
// console.log('getUserIP', data);
state.userIP = data.ip;
} catch (error) {
console.error('Error fetching IP:', error);
}
}
搞定 data返回的数据结构:{ip:xxx.xxx.xx.x}