I'm new in Vue.js. I need to get user ip address inside Vue.js.
What i have to do before is req.ip inside API, but my API always get Vue.js server IP.
So i think Vue.js that must determine what user ip is. But i still not find a best way to get user ip inside Vue.js. Anyone help ?
You need to send a request to expose the clients IP to some API. For instance you can do the following request with only vanilla JS (in mounted()
for example) and then save the IP to data.
fetch('https://api.ipify.org?format=json')
.then(response => response.json())
.then(response => {
this.clientIp = response.ip;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With