Skip to content
Learn Netverks
0

Using ipapi to get ip address

asked 8 hours ago by @qa-qn1pypvbrcsy7vq5xcgj 0 rep · 37 views

jsx ip address

I am running the following code:

import {useEffect, useState} from "react";
import axios from "axios";

function ObterIP() {
    const [ip, setIP] = useState("");
    useEffect(() =>{
        ipUtilizador();
    },[])

    const ipUtilizador = async ( ) => {
        const ip = await axios.get ('https://ipapi.co/json');
        console.log(ip.data);
        setIP(ip.data.ip);
        //funcao para obter data e hora de visita
        const DATA = new Date();
    };
    return<>
        <h1>{ip}</h1>
    </>
}
export default ObterIP;

to get the IP address from my laptop on my website, but when I open the website in the phone it does not show the IP address. Why is that and how can I fix it?

Comments on this question (0)

Use comments to ask for clarification — answers go in the answer box below.

Log in to comment on this question.

0 answers

Your answer